Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write two codes in the places where ' Your code here' is written. class Card(object): cardtype = 'Staff' def __init__(self, name, attack, defense):

please write two codes in the places where ' Your code here' is written.

class Card(object):

cardtype = 'Staff'

def __init__(self, name, attack, defense):

"""

Create a Card object with a name, attack,

and defense.

>>> staff_member = Card('staff', 400, 300)

>>> staff_member.name

'staff'

>>> staff_member.attack

400

>>> staff_member.defense

300

>>> other_staff = Card('other', 300, 500)

>>> other_staff.attack

300

>>> other_staff.defense

500

"""

"*** YOUR CODE HERE ***"

def power(self, other_card):

"""

Calculate power as:

(player card's attack) - (opponent card's defense)/2

where other_card is the opponent's card.

>>> staff_member = Card('staff', 400, 300)

>>> other_staff = Card('other', 300, 500)

>>> staff_member.power(other_staff)

150.0

>>> other_staff.power(staff_member)

150.0

>>> third_card = Card('third', 200, 400)

>>> staff_member.power(third_card)

200.0

>>> third_card.power(staff_member)

50.0

"""

"*** YOUR CODE HERE ***"

?more details(if needed)

Rules of the Game

This game is a little involved, though not nearly as much as its namesake. Here's how it goes:

There are two players. Each player has a hand of cards and a deck, and at the start of each round, each player draws a card from their deck. If a player's deck is empty when they try to draw, they will automatically lose the game. Cards have a name, an attack stat, and a defense stat. Each round, each player chooses one card to play from their own hands. The card with the higher power wins the round. Each played card's power value is calculated as follows:

(player card's attack) - (opponent card's defense) / 2

For example, let's say Player 1 plays a card with 2000 ATK/1000 DEF and Player 2 plays a card with 1500 ATK/3000 DEF. Their cards' powers are calculated as:

P1: 2000 - 3000/2 = 2000 - 1500 = 500

P2: 1500 - 1000/2 = 1500 - 500 = 1000

so Player 2 would win this round.

The first player to win 8 rounds wins the match!

However, there are a few effects we can add (in the optional questions section) to make this game a bit more interesting. Cards are split into Tutor, TA, and Instructor types, and each type has a different effect when they're played. All effects are applied before power is calculated during that round:

A Tutor will cause the opponent to discard and re-draw the first 3 cards in their hand.

A TA will swap the opponent card's attack and defense.

An Instructor will add 300 attack and defense to all cards in the player's deck, and then add a copy of the opponent's card to both the player's deck and the player's hand.

A Professor adds the opponent card's attack and defense to all cards in their deck and then remove all cards in the opponent's deck that share its attack or defense!

These are a lot of rules to remember, so refer back here if you need to review them, and let's start making the game!

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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions