Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- class GameEnity:
- class_name = ""
- desc = ""
- enities = {}
- def __init__(self, name):
- self.name = name
- GameEnity.enities[self.class_name] = self
- def get_desc(self):
- return self.class_name + "\n" + self.desc
- class GameObject:
- class_name = ""
- desc = ""
- objects = {}
- def __init__(self, name):
- self.name = name
- GameObject.objects[self.class_name] = self
- def get_desc(self):
- return self.class_name + "\n" + self.desc
- class GameLocation:
- class_name = ""
- desc = ""
- locations = {}
- def __init__(self, name):
- self.name = name
- GameLocation.locations[self.class_name] = self
- def get_desc(self):
- return self.class_name + "\n" + self.desc
- class GameTerrian:
- class_name = ""
- desc = ""
- terrains = {}
- def __init__(self, name):
- self.name = name
- GameLocation.locations[self.class_name] = self
- def get_desc(self):
- return self.class_name + "\n" + self.desc
- class GameCraft:
- class_name = ""
- desc = ""
- crafts = {}
- def __init__(self, name):
- self.name = name
- GameCraft.crafts[self.class_name] = self
- def get_desc(self):
- return self.class_name + "\n" + self.desc
- class Archer(GameEnity):
- def __init__(self, name):
- self.class_name = "archer"
- self.health = 3
- self._desc = "A king and queen guardian with bow"
- super().__init__(name)
- @property
- def desc(self):
- if self.health >= 3:
- return self._desc
- elif self.health == 2:
- health_line = "It has a wound on its knee."
- elif self.health == 1:
- health_line = "Its left arm has been cut off!"
- elif self.health <= 0:
- health_line = "It is dead."
- return self._desc + "\n" + health_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- archer = Archer("Andy")
- class Merman(GameEnity):
- def __init__(self, name):
- self.class_name = "merman"
- self.health = 0
- self.quantity = 0
- self._desc = "A water creature what live in swamp and can kill"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 1:
- if self.health >= 3:
- return self._desc
- elif self.health == 2:
- health_line = "Its body bleading a lot"
- elif self.health == 1:
- health_line = "Its left arm has been cut off!"
- elif self.health <= 0:
- health_line = "It is dead."
- return self._desc + "\n" + health_line
- else:
- return "There is no merman here"
- @desc.setter
- def desc(self, value):
- self._desc = value
- merman = Merman("Killer")
- class Wolf(GameEnity):
- def __init__(self, name):
- self.class_name = "wolf"
- self.health = 0
- self.quantity = 0
- self._desc = "A creature what live in forest and can kill"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 1:
- if self.health >= 3:
- return self._desc
- elif self.health == 2:
- health_line = "Its body bleading a lot"
- elif self.health == 1:
- health_line = "Its left arm has been cut off!"
- elif self.health <= 0:
- health_line = "It is dead."
- return self._desc + "\n" + health_line
- else:
- return "There is no wolf here"
- @desc.setter
- def desc(self, value):
- self._desc = value
- wolf = Wolf("Killer")
- class Warrior(GameEnity):
- def __init__(self, name):
- self.class_name = "warrior"
- self.health = 0
- self.armor = 0
- self.quantity = 0
- self._desc = "A king and queen guardian with sword and in armor"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 1:
- if self.arcmor <=1:
- if self.health >= 5:
- return self._desc
- elif self.health == 4:
- health_line = "It havs a wound on its knee."
- elif self.health == 3:
- health_line = "It has scars all over its body"
- elif self.health == 2:
- health_line = "Its left arm is bleeding a lot"
- elif self.health == 1:
- health_line = "Its left arm has been cut off!"
- elif self.health <= 0:
- health_line = "It is dead."
- return self._desc + "\n" + health_line
- else:
- if self.armor >=2:
- return self._desc
- elif self.armor == 1:
- armor_line = "Its armor is in very bad condition"
- elif self.armor <= 0:
- armor_line = "Its armor is broken but If It will have allingredients and tools It will repear it"
- return self._desc + "\n" + armor_line
- else:
- return "There is no warrior here"
- @desc.setter
- def desc(self, value):
- self._desc = value
- warrior = Warrior("Thor")
- class Hero(GameEnity):
- def __init__(self, name):
- self.class_name = "hero"
- self.health = 5
- self.armor = 2.5
- self._desc = "A person who want to kill the king"
- super().__init__(name)
- @property
- def desc(self):
- if self.armor >= 1:
- if self.health >= 5:
- return self._desc
- elif self.health == 4:
- health_line = "I have a wound on my knee."
- elif self.health == 3:
- health_line = "I have scars all over my body"
- elif self.health == 2:
- health_line = "My left arm is bleeding a lot"
- elif self.health == 1:
- health_line = "My left arm has been cut off!"
- elif self.health <= 0:
- health_line = "I am dead."
- return self._desc + "\n" + health_line
- else:
- if self.armor >= 2.0:
- return self._desc
- elif self.armor == 1.0:
- armor_line = "My armor is in very bad condition"
- elif self.armor <= 0:
- armor_line = "My armor is broken but If I will have allingredients and tools I will repear it"
- return self._desc + "\n" + armor_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- hero = Hero("Vova")
- class First_Aid_Kit(GameObject):
- def __init__(self, name):
- self.class_name = "aptechka"
- self.quantity = 1
- self.value = 75
- self._desc = "A thing that can restore your health"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity == 5:
- quantity_line = "I have five first aid kits"
- elif self.quantity == 4:
- quantity_line = "I have four first aid kits"
- elif self.quantity == 3:
- quantity_line = "I have three first aid kits"
- elif self.quantity == 2:
- quantity_line = "I have two first aid kits"
- elif self.quantity == 1:
- quantity_line = "I have one first aid kit"
- elif self.quantity == 0:
- quantity_line = "I do not have first aid kits"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- aptechka = First_Aid_Kit("Healka")
- class Repair_Kit(GameObject):
- def __init__(self, name):
- self.class_name = "kit"
- self.quantity = 1
- self.value = 75
- self._desc = "A thing that can restore your armor"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity == 5:
- quantity_line = "I have five repair kits"
- elif self.quantity == 4:
- quantity_line = "I have four repair kits"
- elif self.quantity == 3:
- quantity_line = "I have three repair kits"
- elif self.quantity == 2:
- quantity_line = "I have two repair kits"
- elif self.quantity == 1:
- quantity_line = "I have one repair kit"
- elif self.quantity == 0:
- quantity_line = "I do not have repair kits"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- kit = Repair_Kit("Refitka")
- class Frog(GameObject):
- def __init__(self, name):
- self.class_name = "frog"
- self.quantity = 0
- self.value = 20
- self._desc = "A very terrible food what can restore 0.5 of your health"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many frogs"
- if self.quantity == 5:
- quantity_line = "I have five frogs"
- elif self.quantity == 4:
- quantity_line = "I have four frogs"
- elif self.quantity == 3:
- quantity_line = "I have three frogs"
- elif self.quantity == 2:
- quantity_line = "I have two frogs"
- elif self.quantity == 1:
- quantity_line = "I have one frog"
- elif self.quantity == 0:
- quantity_line = "I do not have frogs"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- frog = Frog("Italian food")
- class A_Dry_Branch(GameObject):
- def __init__(self, name):
- self.class_name = "stick"
- self.quantity = 0
- self.value = 10
- self._desc = "A well-burning stick that is perfect for a bonfire"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many sticks"
- if self.quantity == 5:
- quantity_line = "I have five sticks"
- elif self.quantity == 4:
- quantity_line = "I have four sticks"
- elif self.quantity == 3:
- quantity_line = "I have three sticks"
- elif self.quantity == 2:
- quantity_line = "I have two sticks"
- elif self.quantity == 1:
- quantity_line = "I have one stick"
- elif self.quantity == 0:
- quantity_line = "I do not have sticks"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- stick = A_Dry_Branch("Very good think")
- class Log(GameObject):
- def __init__(self, name):
- self.class_name = "log"
- self.quantity = 0
- self.value = 30
- self._desc = "A well-burning log that is perfect for a bonfire and building"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many log"
- if self.quantity == 5:
- quantity_line = "I have five logs"
- elif self.quantity == 4:
- quantity_line = "I have four logs"
- elif self.quantity == 3:
- quantity_line = "I have three logs"
- elif self.quantity == 2:
- quantity_line = "I have two logs"
- elif self.quantity == 1:
- quantity_line = "I have one log"
- elif self.quantity == 0:
- quantity_line = "I do not have logs"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- log = Log("Very good think")
- class Rock(GameObject):
- def __init__(self, name):
- self.class_name = "rock"
- self.quantity = 0
- self.value = 15
- self._desc = "A rock what is very good for crafts"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many rocks"
- if self.quantity == 5:
- quantity_line = "I have five rocks"
- elif self.quantity == 4:
- quantity_line = "I have four rocks"
- elif self.quantity == 3:
- quantity_line = "I have three rocks"
- elif self.quantity == 2:
- quantity_line = "I have two rocks"
- elif self.quantity == 1:
- quantity_line = "I have one rock"
- elif self.quantity == 0:
- quantity_line = "I do not have rocks"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- rock = Rock("Very good think")
- class Mushroom(GameObject):
- def __init__(self, name):
- self.class_name = "mushroom"
- self.quantity = 0
- self.value = 25
- self._desc = "A rock what is very good for crafts"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many rocks"
- if self.quantity == 5:
- quantity_line = "I have five rocks"
- elif self.quantity == 4:
- quantity_line = "I have four rocks"
- elif self.quantity == 3:
- quantity_line = "I have three rocks"
- elif self.quantity == 2:
- quantity_line = "I have two rocks"
- elif self.quantity == 1:
- quantity_line = "I have one rock"
- elif self.quantity == 0:
- quantity_line = "I do not have rocks"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- mushroom = Mushroom("Very nice thing")
- class Peat(GameObject):
- def __init__(self, name):
- self.class_name = "peat"
- self.quantity = 0
- self.value = 20
- self._desc = "A well-burning peat that is perfect for a bonfire"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many peat"
- if self.quantity == 5:
- quantity_line = "I have five peats"
- elif self.quantity == 4:
- quantity_line = "I have four peats"
- elif self.quantity == 3:
- quantity_line = "I have three peats"
- elif self.quantity == 2:
- quantity_line = "I have two peats"
- elif self.quantity == 1:
- quantity_line = "I have one peat"
- elif self.quantity == 0:
- quantity_line = "I do not have peats"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- peat = Peat("Very good think")
- class Coin(GameObject):
- def __init__(self, name):
- self.class_name = "coin"
- self.quantity = 0
- self._desc = "A сurrency used in all trading operations"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many coins"
- if self.quantity == 5:
- quantity_line = "I have five coins"
- elif self.quantity == 4:
- quantity_line = "I have four coins"
- elif self.quantity == 3:
- quantity_line = "I have three coins"
- elif self.quantity == 2:
- quantity_line = "I have two coins"
- elif self.quantity == 1:
- quantity_line = "I have one coin"
- elif self.quantity == 0:
- quantity_line = "I do not have coins"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- coin = Coin("Currency")
- class Axe(GameCraft):
- def __init__(self, name):
- self.class_name = "axe"
- self.quantity = 0
- self.durability = 0
- self.value = 50
- self._desc = "A instrument to word with wood or chop it"
- super().__init__(name)
- @property
- def desc(self):
- if self.quantity >= 6:
- quantity_line = "I have so many axes"
- if self.quantity == 5:
- quantity_line = "I have five axes"
- elif self.quantity == 4:
- quantity_line = "I have four axes"
- elif self.quantity == 3:
- quantity_line = "I have three axes"
- elif self.quantity == 2:
- quantity_line = "I have two axes"
- elif self.quantity == 1:
- quantity_line = "I have one axe"
- elif self.quantity == 0:
- quantity_line = "I do not have axes"
- return self._desc + "\n" + quantity_line
- @desc.setter
- def desc(self, value):
- self._desc = value
- @property
- def quantity(self):
- if self.durabily >= 0:
- self.quantity -= 1
- @desc.setter
- def quantity(self, value):
- self._desc = value
- axe = Axe("Very good instrument to work with wood")
- class Ruins(GameLocation):
- def __init__(self, name):
- self.class_name = "ruins"
- self._desc = "A place where you can find a first aid kit, repair kit, warrior"
- super().__init__(name)
- ruins = Ruins("Wastland")
- class Forest(GameLocation):
- def __init__(self, name):
- self.class_name = "forest"
- self._desc = "A place where you can find a dry branch, log, mushroom, rock, wolf"
- super().__init__(name)
- forest = Forest("Very good place")
- class Swamp(GameLocation):
- def __init__(self, name):
- self.class_name = "swamp"
- self._desc = "A place where you can find a peat, frog, merman"
- super().__init__(name)
- swamp = Swamp("Dirty water")
- class City(GameLocation):
- def __init__(self, name):
- self.class_name = "city"
- self._desc = "A city where are many shops, homes and a square"
- super().__init__(name)
- city = City("Civilized village")
- class Nature(GameTerrian):
- def __init__(self, name):
- self.class_name = "nature"
- self._desc = "A large area where are a lot of forests, swamp, ruins"
- super().__init__(name)
- nature = Nature("Creatures territory")
- class Kingdom(GameTerrian):
- def __init__(self, name):
- self.class_name = "kindom"
- self._desc = "A large area where are a lot of cities, villages, farms"
- super().__init__(name)
- kingdom = Kingdom("King and queen territory")
- def hit(noun):
- if noun in GameEnity.enities:
- thing = GameEnity.enities[noun]
- if type(thing) == Archer:
- thing.health -= 1
- if hero.armor <= 0:
- if archer.health >= 1:
- hero.health -= 1
- if archer.health <= 3:
- archer.health -= 1
- elif archer.health <= 2:
- archer.health -= 1
- if thing.health <= 0:
- msg = "You killed the archer!"
- else:
- msg = "You hit the {}".format(thing.class_name)
- else:
- if archer.health >= 1:
- hero.armor -= 0.5
- if type(thing) == Warrior:
- if warrior.quantity >= 1:
- if hero.armor <= 0:
- if warrior.health >= 1:
- hero.health -= 1
- elif hero.armor >= 1:
- if warrior.health >= 1:
- hero.armor -= 0.5
- if warrior.armor <= 0:
- thing.health -= 1
- if warrior.health <= 3:
- warrior.health -= 1
- if warrior.health <= 2:
- warrior.health -= 1
- if thing.health <= 0:
- msg = "You killed the warrior!"
- else:
- msg = "You hit the {}".format(thing.class_name)
- else:
- warrior.armor -= 0.5
- if warrior.armor <= 0:
- msg = "You broke the warrior armor!"
- else:
- msg = "You hit the {}".format(thing.class_name)
- if type(thing) == Merman:
- if mermen.quantity >= 1:
- thing.health -= 1
- if hero.armor <= 0:
- if thing.health >= 1:
- hero.health -= 1
- if thing.health <= 3:
- thing.health -= 1
- if thing.health <= 2:
- thing.health -= 1
- if thing.health <= 0:
- msg = "You killed the marmen!"
- else:
- msg = "You hit the {}".format(thing.class_name)
- elif hero.armor >= 1:
- if thing.health >= 1:
- hero.armor -= 0.5
- if type(thing) == Wolf:
- if thing.quantity >= 1:
- thing.health -= 1
- if hero.armor <= 0:
- if thing.health >= 1:
- hero.health -= 1
- if thing.health <= 3:
- thing.health -= 1
- if thing.health <= 2:
- thing.health -= 1
- if thing.health <= 0:
- msg = "You killed the wolf!"
- else:
- msg = "You hit the {}".format(thing.class_name)
- elif hero.armor >= 1:
- if thing.health >= 1:
- hero.armor -= 0.5
- else:
- msg = "There is no {} here.".format(noun)
- return msg
- def travel(noun):
- if noun in GameLocation.locations:
- loc = GameLocation.locations[noun]
- if noun in GameTerrain.terrains:
- ter = GameTerrain.Terrains[noun]
- if type(ter) == Nature:
- territory = 1
- return "You traveled to Nature"
- if type(ter) == Kingdome:
- territory = 2
- return "You traveled to Kingdom"
- if territory == 1:
- if type(loc) == Ruins:
- place = 1.1
- return "You traveled to Ruins"
- if type(loc) == Swamp:
- place = 1.2
- return "You traveled to Swamp"
- if type(loc) == Forest:
- place = 1.3
- return "You traveled to Forest"
- if territory == 2:
- if type(loc) == City:
- place = 2.1
- return "You traveled to City"
- def search(noun):
- if territory == 1:
- if place == 1.1:
- aptechka.quantity = aptechka.quantity + random.random()
- kit.quantity = kit.quantity + random.random()
- warrior.quantity = warrior.quantity + random.random()
- if warrior.health <= 0:
- warrior.health += 5
- if warrior.armor <= 0:
- warrior.armor += 2.5
- return "I searched everywhere and spent two hours on it"
- if place == 1.2:
- frog.quantity = frog.quantity + random.randint(0, 5)
- peat.quantity = peat.quantity + random.randint(0, 5)
- merman.quantity = merman.quantity + random.random()
- if merman.health <= 0:
- merman.health +=5
- return "I searched everywhere and spent two hours on it"
- if place == 1.3:
- stick.quantity = stick.quantity + random.randint(0, 5)
- log.quantity = log.quantity + random.random()
- rock.quantity = rock.quantity + random.randint(0, 10)
- mushroom.quantity = mushroom.quantity + random.randint(0, 5)
- wolf.quantity = wolf.quantity + random.random()
- if wolf.health <= 0:
- wolf.health += 5
- return "I searched everywhere and spent two hours on it"
- if territory == 2:
- if place == 2.1:
- coin.quantity = coin.quantity + random.randint(0, 20)
- return "I searched everywhere and spent two hours on it"
- def craft(noun):
- if noun == bonfire:
- if stick.quantity >= 20:
- stick.quantity -= 20
- if log.quantity >= 3:
- log.quantity -= 3
- bonfire.quantity += 1
- if noun == axe:
- if stick.quantity >= 1:
- stick.quantity -= 1
- if rock.quantity >= 1:
- rock.quantity -= 1
- axe.quantity += 1
- axe.durability += 20
- def buy(noun):
- if noun in GameObject.objects:
- if noun == stick:
- if coin.quantity >= stick.value:
- coin.quantity -= stick.value
- stick.quantity += 1
- return "I bought one stick"
- if noun == rock:
- if coin.quantity >= rock.value:
- coin.quantity -= rock.value
- rock.quantity += 1
- return "I bought one rock"
- if noun == aptechka:
- if coin.quantity >= aptechka.value:
- coin.quantity -= aptechka.value
- aptechka.quantity += 1
- return "I bought one first aid kit"
- if noun == kit:
- if coin.quantity >= kit.value:
- coin.quantity -= kit.value
- kit.quantity += 1
- return "I bought one repair kit"
- if noun == frog:
- if coin.quantity >= frog.value:
- coin.quantity -= frog.value
- frog.quantity += 1
- return "I bought one frog"
- if noun == log:
- if coin.quantity >= log.value:
- coin.quantity -= log.value
- log.quantity += 1
- return "I bought one log"
- if noun == mushroom:
- if coin.quantity >= mushroom.value:
- coin.quantity -= mushroom.value
- mushroom.quantity += 1
- return "I bought one frog"
- if noun == peat:
- if coin.quantity >= peat.value:
- coin.quantity -= peat.value
- peat.quantity += 1
- return "I bought one frog"
- if noun in GameCraft.crafts:
- if noun == axe:
- if coin.quantity >= axe.value:
- coin.quantity -= axe.value
- axe.quantity += 1
- return "I bought one axe"
- def sell(noun):
- if noun in GameObject.objects:
- if noun == stick:
- if stick.quantity >= 1:
- coin.quantity += stick.value
- stick.quantity -= 1
- return "I sold one stick"
- if noun == rock:
- if rock.quantity >= 1:
- coin.quantity += rock.value
- rock.quantity -= 1
- return "I sold one rock"
- if noun == aptechka:
- if aptechka.quantity >= 1:
- coin.quantity += aptechka.value
- ptechka.quantity -= 1
- return "I sold one first aid kit"
- if noun == kit:
- if kit.quantity >= 1:
- coin.quantity += kit.value
- kit.quantity -= 1
- return "I sold one reapir kit"
- if noun == frog:
- if frog.quantity >= 1:
- coin.quantity += frog.value
- frog.quantity -= 1
- return "I sold one frog"
- if noun == log:
- if log.quantity >= 1:
- coin.quantity += log.value
- log.quantity -= 1
- return "I sold one log"
- if noun == myshroom:
- if stick.quantity >= 1:
- coin.quantity += mushroom.value
- mushroom.quantity -= 1
- return "I sold one mushroom"
- if noun == peat:
- if peat.quantity >= 1:
- coin.quantity += peat.value
- peat.quantity -= 1
- return "I sold one peat"
- if noun in GameCraft.crafts:
- if noun == axe:
- if axe.quantity >= 1:
- coin.quantity += axe.value
- axe.quantity -= 1
- return "I sold one axe"
- def heal(noun):
- if noun in GameObject.objects:
- thing = GameObject.objects[noun]
- if type(thing) == aptechka:
- if aptechka.quantity >= 1:
- aptechka.quantity -= 1
- thing.health += 1
- return "I healed my wounds for about an hour"
- else:
- return "You do not have First aid kit"
- if type(thing) == frog:
- if frog.quantity >= 1:
- frog.quantity -= 1
- hero.health += 0.5
- return "I ate and my organism regenarated a bit"
- else:
- return "You do not have frogs"
- def suicide(noun):
- if noun == hero:
- hero.armor -= 5
- hero.health -= 5
- def repair(noun):
- if noun in GameEnity.enities:
- thing = GameEnity.enities[noun]
- if type(thing) == Hero:
- if kit.quantity >= 1:
- kit.quantity -= 1
- thing.armor += 1
- return "I repaired my armor for about an hour"
- else:
- return "You do not have Repair kit"
- def cut(noun):
- if noun == tree:
- axe.durability -= 1
- stick.quantity = stick.quantity + random.randomint(5, 20)
- log.quantity = log.quantity + random.randint(3, 6)
- return "I cut down the tree and plant a seedling of that"
- def examine(noun):
- if noun in GameEnity.enities:
- return GameEnity.enities[noun].get_desc()
- if noun in GameObject.objects:
- return GameObject.objects[noun].get_desc()
- if noun in GameLocation.locations:
- return GameLocation.locations[noun].get_desc()
- if noun in GameTerrian.terrains:
- return GameTerrian.terrains[noun].get_desc()
- if noun in GameCraft.crafts:
- return GameCraft.crafts[noun].get_desc()
- else:
- return "There is no {} here.".format(noun)
- def say(noun):
- return 'You said "{}"'.format(noun)
- def get_input():
- word = input(": ").split()
- verb_word = word[0]
- if verb_word in verb_dict:
- verb = verb_dict[verb_word]
- else:
- print("Unknown verb {}".format(verb_word))
- return
- if len(word) >= 2:
- noun_word = word[1]
- print(verb(noun_word))
- else:
- print(verb("nothing"))
- def damage():
- if hero.armor >= 1:
- if archer.health >= 1:
- hero.armor -= 0.5
- else:
- if archer.health >=1:
- hero.health -= 1
- if warrior.health <= 0:
- warrior.quantity -= 1
- if warrior.quantity >= 1:
- if warrior.health <= 0:
- warrior.health += 5
- if warrior.armor <= 0:
- warrior.armor += 2.5
- if merman.health <= 0:
- merman.quantity -= 1
- if merman.quantity >= 1:
- if merman.health <= 0:
- merman.health += 5
- if wolf.health <= 0:
- wolf.quantity -= 1
- if wolf.quantity >= 1:
- if wolf.health <= 0:
- wolf.health += 5
- if hero.health <= 0:
- sys.exit("Why not")
- verb_dict = {
- "say": say,
- "examine": examine,
- "hit": hit,
- "heal": heal,
- "repair": repair,
- "search": search,
- "craft": craft,
- "cut": cut,
- "buy": buy,
- "sell": sell,
- "suicide": suicide,
- }
- while hero.health >= 1:
- get_input()
- damage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement