SHARE
TWEET

Game 1

Vovan408 Oct 16th, 2019 (edited) 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import sys
  3. class GameEnity:
  4.     class_name = ""
  5.     desc = ""
  6.     enities = {}
  7.  
  8.     def __init__(self, name):
  9.         self.name = name
  10.         GameEnity.enities[self.class_name] = self
  11.  
  12.     def get_desc(self):
  13.         return self.class_name + "\n" + self.desc
  14.  
  15. class GameObject:
  16.     class_name = ""
  17.     desc = ""
  18.     objects = {}
  19.  
  20.     def __init__(self, name):
  21.         self.name = name
  22.         GameObject.objects[self.class_name] = self
  23.  
  24.     def get_desc(self):
  25.         return self.class_name + "\n" + self.desc
  26.  
  27. class GameLocation:
  28.     class_name = ""
  29.     desc = ""
  30.     locations = {}
  31.  
  32.     def __init__(self, name):
  33.         self.name = name
  34.         GameLocation.locations[self.class_name] = self
  35.  
  36.     def get_desc(self):
  37.         return self.class_name + "\n" + self.desc
  38.  
  39. class GameTerrian:
  40.     class_name = ""
  41.     desc = ""
  42.     terrains = {}
  43.  
  44.     def __init__(self, name):
  45.         self.name = name
  46.         GameLocation.locations[self.class_name] = self
  47.  
  48.     def get_desc(self):
  49.         return self.class_name + "\n" + self.desc
  50.  
  51. class GameCraft:
  52.     class_name = ""
  53.     desc = ""
  54.     crafts = {}
  55.  
  56.     def __init__(self, name):
  57.         self.name = name
  58.         GameCraft.crafts[self.class_name] = self
  59.  
  60.     def get_desc(self):
  61.         return self.class_name + "\n" + self.desc
  62.  
  63. class Archer(GameEnity):
  64.     def __init__(self, name):
  65.         self.class_name = "archer"
  66.         self.health = 3
  67.         self._desc = "A king and queen guardian with bow"
  68.         super().__init__(name)
  69.  
  70.     @property
  71.     def desc(self):
  72.         if self.health >= 3:
  73.             return self._desc
  74.         elif self.health == 2:
  75.             health_line = "It has a wound on its knee."
  76.         elif self.health == 1:
  77.             health_line = "Its left arm has been cut off!"
  78.         elif self.health <= 0:
  79.             health_line = "It is dead."
  80.         return self._desc + "\n" + health_line
  81.  
  82.     @desc.setter
  83.     def desc(self, value):
  84.         self._desc = value
  85.  
  86. archer = Archer("Andy")
  87.  
  88. class Merman(GameEnity):
  89.     def __init__(self, name):
  90.         self.class_name = "merman"
  91.         self.health = 0
  92.         self.quantity = 0
  93.         self._desc = "A water creature what live in swamp and can kill"
  94.         super().__init__(name)
  95.  
  96.     @property
  97.     def desc(self):
  98.         if self.quantity >= 1:
  99.             if self.health >= 3:
  100.                 return self._desc
  101.             elif self.health == 2:
  102.                 health_line = "Its body bleading a lot"
  103.             elif self.health == 1:
  104.                 health_line = "Its left arm has been cut off!"
  105.             elif self.health <= 0:
  106.                 health_line = "It is dead."
  107.             return self._desc + "\n" + health_line
  108.         else:
  109.             return "There is no merman here"
  110.  
  111.     @desc.setter
  112.     def desc(self, value):
  113.         self._desc = value
  114.  
  115. merman = Merman("Killer")
  116.  
  117. class Wolf(GameEnity):
  118.     def __init__(self, name):
  119.         self.class_name = "wolf"
  120.         self.health = 0
  121.         self.quantity = 0
  122.         self._desc = "A creature what live in forest and can kill"
  123.         super().__init__(name)
  124.  
  125.     @property
  126.     def desc(self):
  127.         if self.quantity >= 1:
  128.             if self.health >= 3:
  129.                 return self._desc
  130.             elif self.health == 2:
  131.                 health_line = "Its body bleading a lot"
  132.             elif self.health == 1:
  133.                 health_line = "Its left arm has been cut off!"
  134.             elif self.health <= 0:
  135.                 health_line = "It is dead."
  136.             return self._desc + "\n" + health_line
  137.         else:
  138.             return "There is no wolf here"
  139.  
  140.     @desc.setter
  141.     def desc(self, value):
  142.         self._desc = value
  143.  
  144. wolf = Wolf("Killer")
  145.  
  146. class Warrior(GameEnity):
  147.     def __init__(self, name):
  148.         self.class_name = "warrior"
  149.         self.health = 0
  150.         self.armor = 0
  151.         self.quantity = 0
  152.         self._desc = "A king and queen guardian with sword and in armor"
  153.         super().__init__(name)
  154.  
  155.     @property
  156.     def desc(self):
  157.         if self.quantity >= 1:
  158.             if self.arcmor <=1:
  159.                 if self.health >= 5:
  160.                     return self._desc
  161.                 elif self.health == 4:
  162.                     health_line = "It havs a wound on its knee."
  163.                 elif self.health == 3:
  164.                     health_line = "It has scars all over its body"
  165.                 elif self.health == 2:
  166.                     health_line = "Its left arm is bleeding a lot"
  167.                 elif self.health == 1:
  168.                     health_line = "Its left arm has been cut off!"
  169.                 elif self.health <= 0:
  170.                     health_line = "It is dead."
  171.                 return self._desc + "\n" + health_line
  172.             else:
  173.                 if self.armor >=2:
  174.                     return self._desc
  175.                 elif self.armor == 1:
  176.                     armor_line = "Its armor is in very bad condition"
  177.                 elif self.armor <= 0:
  178.                     armor_line = "Its armor is broken but If It will have allingredients and tools It will repear it"
  179.                 return self._desc + "\n" + armor_line
  180.         else:
  181.             return "There is no warrior here"
  182.  
  183.     @desc.setter
  184.     def desc(self, value):
  185.         self._desc = value
  186.  
  187. warrior = Warrior("Thor")
  188.  
  189. class Hero(GameEnity):
  190.     def __init__(self, name):
  191.         self.class_name = "hero"
  192.         self.health = 5
  193.         self.armor = 2.5
  194.         self._desc = "A person who want to kill the king"
  195.         super().__init__(name)
  196.  
  197.     @property
  198.     def desc(self):
  199.         if self.armor >= 1:
  200.             if self.health >= 5:
  201.                 return self._desc
  202.             elif self.health == 4:
  203.                 health_line = "I have a wound on my knee."
  204.             elif self.health == 3:
  205.                 health_line = "I have scars all over my body"
  206.             elif self.health == 2:
  207.                 health_line = "My left arm is bleeding a lot"
  208.             elif self.health == 1:
  209.                 health_line = "My left arm has been cut off!"
  210.             elif self.health <= 0:
  211.                 health_line = "I am dead."
  212.             return self._desc + "\n" + health_line
  213.         else:
  214.             if self.armor >= 2.0:
  215.                 return self._desc
  216.             elif self.armor == 1.0:
  217.                 armor_line = "My armor is in very bad condition"
  218.             elif self.armor <= 0:
  219.                 armor_line = "My armor is broken but If I will have allingredients and tools I will repear it"
  220.                 return self._desc + "\n" + armor_line
  221.  
  222.     @desc.setter
  223.     def desc(self, value):
  224.         self._desc = value
  225.  
  226.  
  227. hero = Hero("Vova")
  228.  
  229.  
  230. class First_Aid_Kit(GameObject):
  231.     def __init__(self, name):
  232.         self.class_name = "aptechka"
  233.         self.quantity = 1
  234.         self.value = 75
  235.         self._desc = "A thing that can restore your health"
  236.         super().__init__(name)
  237.  
  238.     @property
  239.     def desc(self):
  240.         if self.quantity == 5:
  241.             quantity_line = "I have five first aid kits"
  242.         elif self.quantity == 4:
  243.             quantity_line = "I have four first aid kits"
  244.         elif self.quantity == 3:
  245.             quantity_line = "I have three first aid kits"
  246.         elif self.quantity == 2:
  247.             quantity_line = "I have two first aid kits"
  248.         elif self.quantity == 1:
  249.             quantity_line = "I have one first aid kit"
  250.         elif self.quantity == 0:
  251.             quantity_line = "I do not have first aid kits"
  252.         return self._desc + "\n" + quantity_line
  253.  
  254.     @desc.setter
  255.     def desc(self, value):
  256.         self._desc = value
  257.  
  258. aptechka = First_Aid_Kit("Healka")
  259.  
  260.  
  261. class Repair_Kit(GameObject):
  262.     def __init__(self, name):
  263.         self.class_name = "kit"
  264.         self.quantity = 1
  265.         self.value = 75
  266.         self._desc = "A thing that can restore your armor"
  267.         super().__init__(name)
  268.  
  269.     @property
  270.     def desc(self):
  271.         if self.quantity == 5:
  272.             quantity_line = "I have five repair kits"
  273.         elif self.quantity == 4:
  274.             quantity_line = "I have four repair kits"
  275.         elif self.quantity == 3:
  276.             quantity_line = "I have three repair kits"
  277.         elif self.quantity == 2:
  278.             quantity_line = "I have two repair kits"
  279.         elif self.quantity == 1:
  280.             quantity_line = "I have one repair kit"
  281.         elif self.quantity == 0:
  282.             quantity_line = "I do not have repair kits"
  283.         return self._desc + "\n" + quantity_line
  284.  
  285.     @desc.setter
  286.     def desc(self, value):
  287.         self._desc = value
  288.  
  289. kit = Repair_Kit("Refitka")
  290.  
  291. class Frog(GameObject):
  292.     def __init__(self, name):
  293.         self.class_name = "frog"
  294.         self.quantity = 0
  295.         self.value = 20
  296.         self._desc = "A very terrible food what can restore 0.5 of your health"
  297.         super().__init__(name)
  298.  
  299.     @property
  300.     def desc(self):
  301.         if self.quantity >= 6:
  302.             quantity_line = "I have so many frogs"
  303.         if self.quantity == 5:
  304.             quantity_line = "I have five frogs"
  305.         elif self.quantity == 4:
  306.             quantity_line = "I have four frogs"
  307.         elif self.quantity == 3:
  308.             quantity_line = "I have three frogs"
  309.         elif self.quantity == 2:
  310.             quantity_line = "I have two frogs"
  311.         elif self.quantity == 1:
  312.             quantity_line = "I have one frog"
  313.         elif self.quantity == 0:
  314.             quantity_line = "I do not have frogs"
  315.         return self._desc + "\n" + quantity_line
  316.  
  317.     @desc.setter
  318.     def desc(self, value):
  319.         self._desc = value
  320.  
  321. frog = Frog("Italian food")
  322.  
  323. class A_Dry_Branch(GameObject):
  324.     def __init__(self, name):
  325.         self.class_name = "stick"
  326.         self.quantity = 0
  327.         self.value = 10
  328.         self._desc = "A well-burning stick that is perfect for a bonfire"
  329.         super().__init__(name)
  330.  
  331.     @property
  332.     def desc(self):
  333.         if self.quantity >= 6:
  334.             quantity_line = "I have so many sticks"
  335.         if self.quantity == 5:
  336.             quantity_line = "I have five sticks"
  337.         elif self.quantity == 4:
  338.             quantity_line = "I have four sticks"
  339.         elif self.quantity == 3:
  340.             quantity_line = "I have three sticks"
  341.         elif self.quantity == 2:
  342.             quantity_line = "I have two sticks"
  343.         elif self.quantity == 1:
  344.             quantity_line = "I have one stick"
  345.         elif self.quantity == 0:
  346.             quantity_line = "I do not have sticks"
  347.         return self._desc + "\n" + quantity_line
  348.  
  349.     @desc.setter
  350.     def desc(self, value):
  351.         self._desc = value
  352.        
  353. stick = A_Dry_Branch("Very good think")
  354.  
  355. class Log(GameObject):
  356.     def __init__(self, name):
  357.         self.class_name = "log"
  358.         self.quantity = 0
  359.         self.value = 30
  360.         self._desc = "A well-burning log that is perfect for a bonfire and building"
  361.         super().__init__(name)
  362.  
  363.     @property
  364.     def desc(self):
  365.         if self.quantity >= 6:
  366.             quantity_line = "I have so many log"
  367.         if self.quantity == 5:
  368.             quantity_line = "I have five logs"
  369.         elif self.quantity == 4:
  370.             quantity_line = "I have four logs"
  371.         elif self.quantity == 3:
  372.             quantity_line = "I have three logs"
  373.         elif self.quantity == 2:
  374.             quantity_line = "I have two logs"
  375.         elif self.quantity == 1:
  376.             quantity_line = "I have one log"
  377.         elif self.quantity == 0:
  378.             quantity_line = "I do not have logs"
  379.         return self._desc + "\n" + quantity_line
  380.  
  381.     @desc.setter
  382.     def desc(self, value):
  383.         self._desc = value
  384.        
  385. log = Log("Very good think")
  386.  
  387. class Rock(GameObject):
  388.     def __init__(self, name):
  389.         self.class_name = "rock"
  390.         self.quantity = 0
  391.         self.value = 15
  392.         self._desc = "A rock what is very good for crafts"
  393.         super().__init__(name)
  394.  
  395.     @property
  396.     def desc(self):
  397.         if self.quantity >= 6:
  398.             quantity_line = "I have so many rocks"
  399.         if self.quantity == 5:
  400.             quantity_line = "I have five rocks"
  401.         elif self.quantity == 4:
  402.             quantity_line = "I have four rocks"
  403.         elif self.quantity == 3:
  404.             quantity_line = "I have three rocks"
  405.         elif self.quantity == 2:
  406.             quantity_line = "I have two rocks"
  407.         elif self.quantity == 1:
  408.             quantity_line = "I have one rock"
  409.         elif self.quantity == 0:
  410.             quantity_line = "I do not have rocks"
  411.         return self._desc + "\n" + quantity_line
  412.  
  413.     @desc.setter
  414.     def desc(self, value):
  415.         self._desc = value
  416.        
  417. rock = Rock("Very good think")
  418.  
  419. class Mushroom(GameObject):
  420.     def __init__(self, name):
  421.         self.class_name = "mushroom"
  422.         self.quantity = 0
  423.         self.value = 25
  424.         self._desc = "A rock what is very good for crafts"
  425.         super().__init__(name)
  426.  
  427.     @property
  428.     def desc(self):
  429.         if self.quantity >= 6:
  430.             quantity_line = "I have so many rocks"
  431.         if self.quantity == 5:
  432.             quantity_line = "I have five rocks"
  433.         elif self.quantity == 4:
  434.             quantity_line = "I have four rocks"
  435.         elif self.quantity == 3:
  436.             quantity_line = "I have three rocks"
  437.         elif self.quantity == 2:
  438.             quantity_line = "I have two rocks"
  439.         elif self.quantity == 1:
  440.             quantity_line = "I have one rock"
  441.         elif self.quantity == 0:
  442.             quantity_line = "I do not have rocks"
  443.         return self._desc + "\n" + quantity_line
  444.  
  445.     @desc.setter
  446.     def desc(self, value):
  447.         self._desc = value
  448.        
  449. mushroom = Mushroom("Very nice thing")
  450.  
  451. class Peat(GameObject):
  452.     def __init__(self, name):
  453.         self.class_name = "peat"
  454.         self.quantity = 0
  455.         self.value = 20
  456.         self._desc = "A well-burning peat that is perfect for a bonfire"
  457.         super().__init__(name)
  458.  
  459.     @property
  460.     def desc(self):
  461.         if self.quantity >= 6:
  462.             quantity_line = "I have so many peat"
  463.         if self.quantity == 5:
  464.             quantity_line = "I have five peats"
  465.         elif self.quantity == 4:
  466.             quantity_line = "I have four peats"
  467.         elif self.quantity == 3:
  468.             quantity_line = "I have three peats"
  469.         elif self.quantity == 2:
  470.             quantity_line = "I have two peats"
  471.         elif self.quantity == 1:
  472.             quantity_line = "I have one peat"
  473.         elif self.quantity == 0:
  474.             quantity_line = "I do not have peats"
  475.         return self._desc + "\n" + quantity_line
  476.  
  477.     @desc.setter
  478.     def desc(self, value):
  479.         self._desc = value
  480.        
  481. peat = Peat("Very good think")
  482.  
  483. class Coin(GameObject):
  484.     def __init__(self, name):
  485.         self.class_name = "coin"
  486.         self.quantity = 0
  487.         self._desc = "A сurrency used in all trading operations"
  488.         super().__init__(name)
  489.  
  490.     @property
  491.     def desc(self):
  492.         if self.quantity >= 6:
  493.             quantity_line = "I have so many coins"
  494.         if self.quantity == 5:
  495.             quantity_line = "I have five coins"
  496.         elif self.quantity == 4:
  497.             quantity_line = "I have four coins"
  498.         elif self.quantity == 3:
  499.             quantity_line = "I have three coins"
  500.         elif self.quantity == 2:
  501.             quantity_line = "I have two coins"
  502.         elif self.quantity == 1:
  503.             quantity_line = "I have one coin"
  504.         elif self.quantity == 0:
  505.             quantity_line = "I do not have coins"
  506.         return self._desc + "\n" + quantity_line
  507.  
  508.     @desc.setter
  509.     def desc(self, value):
  510.         self._desc = value
  511.        
  512. coin = Coin("Currency")
  513.  
  514. class Axe(GameCraft):
  515.     def __init__(self, name):
  516.         self.class_name = "axe"
  517.         self.quantity = 0
  518.         self.durability = 0
  519.         self.value = 50
  520.         self._desc = "A instrument to word with wood or chop it"
  521.         super().__init__(name)
  522.  
  523.     @property
  524.     def desc(self):
  525.         if self.quantity >= 6:
  526.             quantity_line = "I have so many axes"
  527.         if self.quantity == 5:
  528.             quantity_line = "I have five axes"
  529.         elif self.quantity == 4:
  530.             quantity_line = "I have four axes"
  531.         elif self.quantity == 3:
  532.             quantity_line = "I have three axes"
  533.         elif self.quantity == 2:
  534.             quantity_line = "I have two axes"
  535.         elif self.quantity == 1:
  536.             quantity_line = "I have one axe"
  537.         elif self.quantity == 0:
  538.             quantity_line = "I do not have axes"
  539.         return self._desc + "\n" + quantity_line
  540.    
  541.     @desc.setter
  542.     def desc(self, value):
  543.         self._desc = value
  544.  
  545.     @property
  546.     def quantity(self):
  547.         if self.durabily >= 0:
  548.             self.quantity -= 1
  549.  
  550.     @desc.setter
  551.     def quantity(self, value):
  552.         self._desc = value
  553.        
  554. axe = Axe("Very good instrument to work with wood")
  555.  
  556.  
  557. class Ruins(GameLocation):
  558.     def __init__(self, name):
  559.         self.class_name = "ruins"
  560.         self._desc = "A place where you can find a first aid kit, repair kit, warrior"
  561.         super().__init__(name)
  562.  
  563. ruins = Ruins("Wastland")
  564.  
  565. class Forest(GameLocation):
  566.     def __init__(self, name):
  567.         self.class_name = "forest"
  568.         self._desc = "A place where you can find a dry branch, log, mushroom, rock, wolf"
  569.         super().__init__(name)
  570.  
  571. forest = Forest("Very good place")
  572.  
  573. class Swamp(GameLocation):
  574.     def __init__(self, name):
  575.         self.class_name = "swamp"
  576.         self._desc = "A place where you can find a peat, frog, merman"
  577.         super().__init__(name)
  578.  
  579. swamp = Swamp("Dirty water")
  580.  
  581. class City(GameLocation):
  582.     def __init__(self, name):
  583.         self.class_name = "city"
  584.         self._desc = "A city where are many shops, homes and a square"
  585.         super().__init__(name)
  586.  
  587. city = City("Civilized village")
  588.  
  589. class Nature(GameTerrian):
  590.     def __init__(self, name):
  591.         self.class_name = "nature"
  592.         self._desc = "A large area where are a lot of forests, swamp, ruins"
  593.         super().__init__(name)
  594.  
  595. nature = Nature("Creatures territory")
  596.  
  597. class Kingdom(GameTerrian):
  598.     def __init__(self, name):
  599.         self.class_name = "kindom"
  600.         self._desc = "A large area where are a lot of cities, villages, farms"
  601.         super().__init__(name)
  602.  
  603. kingdom = Kingdom("King and queen territory")
  604.  
  605. def hit(noun):
  606.     if noun in GameEnity.enities:
  607.         thing = GameEnity.enities[noun]
  608.         if type(thing) == Archer:
  609.             thing.health -= 1
  610.             if hero.armor <= 0:
  611.                 if archer.health >= 1:
  612.                     hero.health -= 1
  613.                 if archer.health <= 3:
  614.                     archer.health -= 1
  615.                 elif archer.health <= 2:
  616.                     archer.health -= 1
  617.                 if thing.health <= 0:
  618.                     msg = "You killed the archer!"
  619.                 else:
  620.                     msg = "You hit the {}".format(thing.class_name)
  621.             else:
  622.                 if archer.health >= 1:
  623.                     hero.armor -= 0.5
  624.         if type(thing) == Warrior:
  625.             if warrior.quantity >= 1:
  626.                 if hero.armor <= 0:
  627.                     if warrior.health >= 1:
  628.                         hero.health -= 1
  629.                 elif hero.armor >= 1:
  630.                     if warrior.health >= 1:
  631.                         hero.armor -= 0.5
  632.                 if warrior.armor <= 0:
  633.                     thing.health -= 1
  634.                     if warrior.health <= 3:
  635.                         warrior.health -= 1
  636.                     if warrior.health <= 2:
  637.                         warrior.health -= 1
  638.                     if thing.health <= 0:
  639.                         msg = "You killed the warrior!"
  640.                     else:
  641.                         msg = "You hit the {}".format(thing.class_name)
  642.                 else:
  643.                     warrior.armor -= 0.5
  644.                     if warrior.armor <= 0:
  645.                         msg = "You broke the warrior armor!"
  646.                     else:
  647.                         msg = "You hit the {}".format(thing.class_name)
  648.         if type(thing) == Merman:
  649.             if mermen.quantity >= 1:
  650.                 thing.health -= 1
  651.                 if hero.armor <= 0:
  652.                     if thing.health >= 1:
  653.                         hero.health -= 1
  654.                     if thing.health <= 3:
  655.                         thing.health -= 1
  656.                     if thing.health <= 2:
  657.                         thing.health -= 1
  658.                     if thing.health <= 0:
  659.                         msg = "You killed the marmen!"
  660.                     else:
  661.                         msg = "You hit the {}".format(thing.class_name)
  662.                 elif hero.armor >= 1:
  663.                     if thing.health >= 1:
  664.                         hero.armor -= 0.5
  665.         if type(thing) == Wolf:
  666.             if thing.quantity >= 1:
  667.                 thing.health -= 1
  668.                 if hero.armor <= 0:
  669.                     if thing.health >= 1:
  670.                         hero.health -= 1
  671.                     if thing.health <= 3:
  672.                         thing.health -= 1
  673.                     if thing.health <= 2:
  674.                         thing.health -= 1
  675.                     if thing.health <= 0:
  676.                         msg = "You killed the wolf!"
  677.                     else:
  678.                         msg = "You hit the {}".format(thing.class_name)
  679.                 elif hero.armor >= 1:
  680.                     if thing.health >= 1:
  681.                         hero.armor -= 0.5
  682.     else:
  683.         msg = "There is no {} here.".format(noun)
  684.     return msg
  685.  
  686. def travel(noun):
  687.     if noun in GameLocation.locations:
  688.         loc = GameLocation.locations[noun]
  689.     if noun in GameTerrain.terrains:
  690.         ter = GameTerrain.Terrains[noun]
  691.         if type(ter) == Nature:
  692.             territory = 1
  693.             return "You traveled to Nature"
  694.         if type(ter) == Kingdome:
  695.             territory = 2
  696.             return "You traveled to Kingdom"
  697.         if territory == 1:
  698.             if type(loc) == Ruins:
  699.                 place = 1.1
  700.                 return "You traveled to Ruins"
  701.             if type(loc) == Swamp:
  702.                 place = 1.2
  703.                 return "You traveled to Swamp"
  704.             if type(loc) == Forest:
  705.                 place = 1.3
  706.                 return "You traveled to Forest"
  707.         if territory == 2:
  708.             if type(loc) == City:
  709.                 place = 2.1
  710.                 return "You traveled to City"
  711.        
  712. def search(noun):
  713.     if territory == 1:
  714.         if place == 1.1:
  715.             aptechka.quantity = aptechka.quantity + random.random()
  716.             kit.quantity = kit.quantity + random.random()
  717.             warrior.quantity = warrior.quantity + random.random()
  718.             if warrior.health <= 0:
  719.                 warrior.health += 5
  720.                 if warrior.armor <= 0:
  721.                     warrior.armor += 2.5
  722.         return "I searched everywhere and spent two hours on it"
  723.         if place == 1.2:
  724.             frog.quantity = frog.quantity + random.randint(0, 5)
  725.             peat.quantity = peat.quantity + random.randint(0, 5)
  726.             merman.quantity = merman.quantity + random.random()
  727.             if merman.health <= 0:
  728.                 merman.health +=5
  729.         return "I searched everywhere and spent two hours on it"
  730.         if place == 1.3:
  731.             stick.quantity = stick.quantity + random.randint(0, 5)
  732.             log.quantity = log.quantity + random.random()
  733.             rock.quantity = rock.quantity + random.randint(0, 10)
  734.             mushroom.quantity = mushroom.quantity + random.randint(0, 5)
  735.             wolf.quantity = wolf.quantity + random.random()
  736.             if wolf.health <= 0:
  737.                 wolf.health += 5
  738.         return "I searched everywhere and spent two hours on it"
  739.     if territory == 2:
  740.         if place == 2.1:
  741.             coin.quantity = coin.quantity + random.randint(0, 20)
  742.         return "I searched everywhere and spent two hours on it"
  743.                      
  744. def craft(noun):
  745.     if noun == bonfire:
  746.         if stick.quantity >= 20:
  747.             stick.quantity -= 20
  748.             if log.quantity >= 3:
  749.                 log.quantity -= 3
  750.                 bonfire.quantity += 1
  751.     if noun == axe:
  752.         if stick.quantity >= 1:
  753.             stick.quantity -= 1
  754.             if rock.quantity >= 1:
  755.                 rock.quantity -= 1
  756.                 axe.quantity += 1
  757.                 axe.durability += 20
  758.  
  759. def buy(noun):
  760.     if noun in GameObject.objects:
  761.         if noun == stick:
  762.             if coin.quantity >= stick.value:
  763.                 coin.quantity -= stick.value
  764.                 stick.quantity += 1
  765.                 return "I bought one stick"
  766.         if noun == rock:
  767.             if coin.quantity >= rock.value:
  768.                 coin.quantity -= rock.value
  769.                 rock.quantity += 1
  770.                 return "I bought one rock"
  771.         if noun == aptechka:
  772.             if coin.quantity >= aptechka.value:
  773.                 coin.quantity -= aptechka.value
  774.                 aptechka.quantity += 1
  775.                 return "I bought one first aid kit"
  776.         if noun == kit:
  777.             if coin.quantity >= kit.value:
  778.                 coin.quantity -= kit.value
  779.                 kit.quantity += 1
  780.                 return "I bought one repair kit"
  781.         if noun == frog:
  782.             if coin.quantity >= frog.value:
  783.                 coin.quantity -= frog.value
  784.                 frog.quantity += 1
  785.                 return "I bought one frog"
  786.         if noun == log:
  787.             if coin.quantity >= log.value:
  788.                 coin.quantity -= log.value
  789.                 log.quantity += 1
  790.                 return "I bought one log"
  791.         if noun == mushroom:
  792.             if coin.quantity >= mushroom.value:
  793.                 coin.quantity -= mushroom.value
  794.                 mushroom.quantity += 1
  795.                 return "I bought one frog"
  796.         if noun == peat:
  797.             if coin.quantity >= peat.value:
  798.                 coin.quantity -= peat.value
  799.                 peat.quantity += 1
  800.                 return "I bought one frog"
  801.     if noun in GameCraft.crafts:
  802.         if noun == axe:
  803.             if coin.quantity >= axe.value:
  804.                 coin.quantity -= axe.value
  805.                 axe.quantity += 1
  806.                 return "I bought one axe"
  807.  
  808. def sell(noun):
  809.     if noun in GameObject.objects:
  810.         if noun == stick:
  811.             if stick.quantity >= 1:
  812.                 coin.quantity += stick.value
  813.                 stick.quantity -= 1
  814.                 return "I sold one stick"
  815.         if noun == rock:
  816.             if rock.quantity >= 1:
  817.                 coin.quantity += rock.value
  818.                 rock.quantity -= 1
  819.                 return "I sold one rock"
  820.         if noun == aptechka:
  821.             if aptechka.quantity >= 1:
  822.                 coin.quantity += aptechka.value
  823.                 ptechka.quantity -= 1
  824.                 return "I sold one first aid kit"
  825.         if noun == kit:
  826.             if kit.quantity >= 1:
  827.                 coin.quantity += kit.value
  828.                 kit.quantity -= 1
  829.                 return "I sold one reapir kit"
  830.         if noun == frog:
  831.             if frog.quantity >= 1:
  832.                 coin.quantity += frog.value
  833.                 frog.quantity -= 1
  834.                 return "I sold one frog"
  835.         if noun == log:
  836.             if log.quantity >= 1:
  837.                 coin.quantity += log.value
  838.                 log.quantity -= 1
  839.                 return "I sold one log"
  840.         if noun == myshroom:
  841.             if stick.quantity >= 1:
  842.                 coin.quantity += mushroom.value
  843.                 mushroom.quantity -= 1
  844.                 return "I sold one mushroom"
  845.         if noun == peat:
  846.             if peat.quantity >= 1:
  847.                 coin.quantity += peat.value
  848.                 peat.quantity -= 1
  849.                 return "I sold one peat"
  850.     if noun in GameCraft.crafts:
  851.         if noun == axe:
  852.             if axe.quantity >= 1:
  853.                 coin.quantity += axe.value
  854.                 axe.quantity -= 1
  855.                 return "I sold one axe"
  856.        
  857. def heal(noun):
  858.     if noun in GameObject.objects:
  859.         thing = GameObject.objects[noun]
  860.         if type(thing) == aptechka:
  861.             if aptechka.quantity >= 1:
  862.                 aptechka.quantity -= 1
  863.                 thing.health += 1
  864.                 return "I healed my wounds for about an hour"
  865.             else:
  866.                 return "You do not have First aid kit"
  867.         if type(thing) == frog:
  868.             if frog.quantity >= 1:
  869.                 frog.quantity -= 1
  870.                 hero.health += 0.5
  871.                 return "I ate and my organism regenarated a bit"
  872.             else:
  873.                 return "You do not have frogs"
  874.  
  875. def suicide(noun):
  876.     if noun == hero:
  877.         hero.armor -= 5
  878.         hero.health -= 5
  879.        
  880. def repair(noun):
  881.     if noun in GameEnity.enities:
  882.         thing = GameEnity.enities[noun]
  883.         if type(thing) == Hero:
  884.             if kit.quantity >= 1:
  885.                 kit.quantity -= 1
  886.                 thing.armor += 1
  887.                 return "I repaired my armor for about an hour"
  888.             else:
  889.                 return "You do not have Repair kit"
  890.  
  891. def cut(noun):
  892.     if noun == tree:
  893.         axe.durability -= 1
  894.         stick.quantity = stick.quantity + random.randomint(5, 20)
  895.         log.quantity = log.quantity + random.randint(3, 6)
  896.         return "I cut down the tree and plant a seedling of that"
  897.  
  898. def examine(noun):
  899.     if noun in GameEnity.enities:
  900.         return GameEnity.enities[noun].get_desc()
  901.     if noun in GameObject.objects:
  902.         return GameObject.objects[noun].get_desc()
  903.     if noun in GameLocation.locations:
  904.         return GameLocation.locations[noun].get_desc()
  905.     if noun in GameTerrian.terrains:
  906.         return GameTerrian.terrains[noun].get_desc()
  907.     if noun in GameCraft.crafts:
  908.         return GameCraft.crafts[noun].get_desc()
  909.     else:
  910.         return "There is no {} here.".format(noun)
  911.  
  912. def say(noun):
  913.     return 'You said "{}"'.format(noun)
  914.  
  915.  
  916. def get_input():
  917.     word = input(": ").split()
  918.     verb_word = word[0]
  919.     if verb_word in verb_dict:
  920.         verb = verb_dict[verb_word]
  921.     else:
  922.         print("Unknown verb {}".format(verb_word))
  923.         return
  924.  
  925.     if len(word) >= 2:
  926.         noun_word = word[1]
  927.         print(verb(noun_word))
  928.     else:
  929.         print(verb("nothing"))
  930.  
  931. def damage():
  932.     if hero.armor >= 1:
  933.         if archer.health >= 1:
  934.             hero.armor -= 0.5
  935.     else:
  936.         if archer.health >=1:
  937.             hero.health -= 1
  938.     if warrior.health <= 0:
  939.         warrior.quantity -= 1
  940.         if warrior.quantity >= 1:
  941.             if warrior.health <= 0:
  942.                 warrior.health += 5
  943.             if warrior.armor <= 0:
  944.                 warrior.armor += 2.5
  945.     if merman.health <= 0:
  946.         merman.quantity -= 1
  947.         if merman.quantity >= 1:
  948.             if merman.health <= 0:
  949.                 merman.health += 5
  950.     if wolf.health <= 0:
  951.         wolf.quantity -= 1
  952.         if wolf.quantity >= 1:
  953.             if wolf.health <= 0:
  954.                 wolf.health += 5
  955.     if hero.health <= 0:
  956.         sys.exit("Why not")
  957.    
  958. verb_dict = {
  959.     "say": say,
  960.     "examine": examine,
  961.     "hit": hit,
  962.     "heal": heal,
  963.     "repair": repair,
  964.     "search": search,
  965.     "craft": craft,
  966.     "cut": cut,
  967.     "buy": buy,
  968.     "sell": sell,
  969.     "suicide": suicide,
  970. }
  971.  
  972. while hero.health >= 1:
  973.     get_input()
  974.     damage()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top