Skip to content

rmotr-group-assignments/pyp-c3-a1-b4-g3-t3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

[pyp-c3-a1] Role-playing game

We're going to code a role-playing game similar to Rock-paper-scissors. But instead of playing with Rocks and Scissors we're going to use funnier things.

The game allows you to create a character and select different skills from the given character. Available skills are:

  • Super strength
  • Flying
  • Super speed

When you start the game you can choose 2 and only 2 skills. Once you've created your character the computer will generate a random character with 2 random skills. Then the game starts and both characters "fight". The winner will be decided based on the skills of the opponents. These are the rules:

  • Strength wins over speed
  • Flying wins over strength
  • Speed wins over Flying

The game can be won, lost or tied based on the skills you've chosen and the ones randomly generated by the computer. Here you can see an example:

asciicast

Code

To code this game you'll need to use Multiple Inheritance or Mixins and (optionally) metaclasses. For example, skills will be encoded as classes:

class FlyingTrait(GameCharacterTrait):
    pass


class SuperSpeedTrait(GameCharacterTrait):
    pass

And a character can be coded as a class that inherits from those classes:

class Character(SuperSpeedTrait, FlyingTrait):
    pass

At any point a character will have a method fight that will be polymorphic and will receive other opponent. Example: my_opponent.figth(computer_opponent) The result of that operation will indicate which opponent won the fight.

Extra

More skills

Try adding more skills to your game. This might be useful: https://en.wikipedia.org/wiki/Zero-sum_game

Different attacks

Every skill can have different attacks. For example Super Strength can have Power kick and Power punch with different values and Super Speed can have fast punch and fast kick. Now the rules are more complex, because fast kick wins over Power punch. But using fast kick can reduce your energy and the next attack can kill you.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published