Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

'' ex4 ' Write a function Duel that takes as input two Creatures card and returns the name of the Creature that wins the duel.

''

ex4

' Write a function Duel that takes as input two Creatures card and returns the name of the Creature that wins the duel. In case of draw, the function will return the string 'Draw'. The following are the rules for the duel:

1) For the sake of semplicity, we will call the two creatures involved in the duel 'Creature 1' and 'Creature 2' 2) If Creature 1 has the attack value >= than Creature 2 defense value, Creature 1 wins the duel. 3) If Creature 2 has the attack value >= than Creature 1 defense value, Creature 2 wins the duel. 4) If Creature 1 has the attack value >= than Creature 2 defense, and if Creature 2 has the attack value >= than Creature 1 defense value, there is a Draw. '''

import mtg

if __name__ == "__main__": pass

by using python mtg.py= File that contains classed and functions

to test the code ex1

Dear student, you woke up in a mystical and magical world. You feel a strange power flowing through the veins. You are a Planeswalker! You are now able to control mana and creatures, and since you are a good Python programmer, you decide to write a Python class that helps you in managing duels in the Magic the Gathering world. In this first exercise, you need to create 4 classes in order to manage the different types of cards.

The first class, namely the base class for cards, has to be named Card, and it must contain the following attributes: - Name of the card --> name, a string - Tap Status --> isTapped, boolean - Type of the card --> card_type, a string

The second class, namely the card that gives mana to a PlanesWalker, is called ManaCard, and inherits attributes and methods from the Card. In addition to the latter, it has the following attributes: - Card type --> card_type = 'mana', a string - How much mana the card gives to the planeswalker --> mana_qty, a integer number

The third class, namely the class that contains creatures data, must be called Creature, and also this class inherits attributes and methods from the Card. In addition to the latter, it has the following attributes: - Card type --> card_type = 'creature', a string - Mana cost to be casted --> mana_cost, an integer number - Attack Value --> attack, an integer number - Defense Value --> defense, an integer number

The last class is the Planeswalker class. It has to be named PlanesWalker, and it contains the following attributes: - Name of the PlanesWalker --> name, a string - Mana cards list --> mana, a list of mana cards - Creatures card list --> creatures, a list of creatures card - Quantity of mana available --> mana_qty, an integer number. This attribute is NOT PASSED AS ARGUMENT, and ITS DEFAULT VALUE IS 0.

Be sure to create a correct __init__ function for each of the classes and to correctly inherits data from the base class (if necessary).

'''

ex2

''' Write a method AddMana in the PlanesWalker class that take as arguments a number of mana cards X, and adds mana quantity to the PlanesWalker as follows:

- The method checks that the PlanesWalker has *at least* X mana cards. If this is NOT TRUE, the method returns False; - If the PlanesWalker has at least X mana cards, the method will look for the first X cards of the mana card list and will add their mana_qty to the PlanesWalker mana_qty. In addition, the value isTapped for the first X cards must be set to True. Finally, the method returns True. '''

ex3

''' Write a function PlayCreatureCheck that takes as input a Creature card and a PlanesWalker and check the following conditions:

- If the card isTapped attribute is True, the function return False; - If the card isTapped attribute is False, then the following actions must be performed: * If the mana_cost of the creature is greater than the mana_qty of the PlanesWalkers, the function return False * If the mana_cost of the creature is lower than the mana_qty of the PlanesWalkers, the function subtract the mana cost of the creatures from the mana_qty of the PlanesWalker, isTapped is set to True, and the function returns True '''

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe how to set up a loan amortization schedule. L026

Answered: 1 week ago

Question

What does the central processing unit ( CPU ) do ?

Answered: 1 week ago