You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# coding: utf-8
# license: GPLv3
from gameunit import *
from random import randint , choice
class Enemy ( Attacker ) :
pass
def generate_random_enemy ( ) :
RandomEnemyType = choice ( enemy_types )
enemy = RandomEnemyType ( )
return enemy
def generate_dragon_list ( enemy_number ) :
enemy_list = [ generate_random_enemy ( ) for i in range ( enemy_number ) ]
return enemy_list
class Dragon ( Enemy ) :
def set_answer ( self , answer ) :
self . __answer = answer
def check_answer ( self , answer ) :
return answer == self . __answer
class GreenDragon ( Dragon ) :
def __init__ ( self ) :
self . _health = 200
self . _attack = 10
self . _color = ' зелёный '
def question ( self ) :
x = randint ( 1 , 100 )
y = randint ( 1 , 100 )
self . __quest = str ( x ) + ' + ' + str ( y )
self . set_answer ( x + y )
return self . __quest
class RedDragon ( Dragon ) :
def __init__ ( self ) :
self . _health = 200
self . _attack = 10
self . _color = ' красный '
def question ( self ) :
x = randint ( 1 , 100 )
y = randint ( 1 , 100 )
self . __quest = str ( x ) + ' - ' + str ( y )
self . set_answer ( x - y )
return self . __quest
class BlackDragon ( Dragon ) :
def __init__ ( self ) :
self . _health = 200
self . _attack = 10
self . _color = ' чёрный '
def question ( self ) :
x = randint ( 1 , 100 )
y = randint ( 1 , 100 )
self . __quest = str ( x ) + ' * ' + str ( y )
self . set_answer ( x * y )
return self . __quest
#FIXME здесь также должны быть описаны классы RedDragon и BlackDragon
# красный дракон учит вычитанию, а чёрный -- умножению.
enemy_types = [ GreenDragon , RedDragon , BlackDragon ]