-
Notifications
You must be signed in to change notification settings - Fork 5
Game Objects
If you want to create a game of your own for the t_games package, you will need to do two things at a minimum. First, the name of the program file for the game will need to end in '_game.py'. Second, you will need a class for the game that inherits from game.Game. The game.Game class has a bunch of methods you can override so that a lot of work is done for you behind the scenes. For information on how to use those methods, see the game programming tutorials:
If you programmed a game before release v0.50.51a1, you should check out Upgrading Card Games (v0.50.51a1) for backward compatibility breaking changes to the cards.py objects. If you want your game to become part of the original t_games repository, please check out Requirements for t_games Games.
If you don't care for the standard Game.game methods, you can override everything in the game. But there are some things used by the t_games interface that you will need to keep:
- A name class attribute (str) with the name of the game.
- The
__init__method needs to take four parameters:- A player.Player class representing the human.
- A str with the raw options given with the play command from the interface.
- An interface.Interface object representing the interface the command came from.
- A boolean object as a flag for silencing certain game messages.
- The class will need a play method that takes no parameters, to start the game going.
- The play method needs to return a results list of [wins, losses, draws, human score, turns played, an integer with bitwise flags, a string of options used] See game.Game.play docs for more information.
Those three things should allow your game to work with the t_games interface.