recurse_try.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. '''
  2. Created on 17 mars 2019
  3. @author: olinox
  4. '''
  5. class Base(): pass
  6. class Location(Base):
  7. name = ""
  8. passable = False
  9. class SpecialLocation(Location):
  10. pass
  11. class DishWasher(SpecialLocation):
  12. pass
  13. class IcecreamCrate(SpecialLocation):
  14. pass
  15. class BlueberriesCrate(SpecialLocation):
  16. pass
  17. class StrawberriesCrate(SpecialLocation):
  18. pass
  19. class DoughCrate(SpecialLocation):
  20. pass
  21. class ChoppingBoard(SpecialLocation):
  22. pass
  23. class Recipe(Base):
  24. location = None
  25. cooking_time = 0
  26. requirements = []
  27. needs_free_hands = False
  28. def available(self):
  29. return []
  30. def get(self):
  31. pass
  32. # if available:
  33. # # get it
  34. # else:
  35. # # does it have requirements?
  36. # # if it has requirements that we don't hold:
  37. # # recurse on those.
  38. #
  39. # # if it has requirements that we hold:
  40. # # does it have a cooking time?
  41. #
  42. # # if yes: cook it
  43. # # if no: go to self.location
  44. class FinalProduct(Recipe):
  45. needs_dish = True
  46. class Ingredient(Recipe):
  47. needs_free_hands = True
  48. class Dish(Recipe):
  49. location = DishWasher
  50. class IceCream(FinalProduct):
  51. location = IcecreamCrate
  52. class Blueberries(FinalProduct):
  53. location = BlueberriesCrate
  54. class Strawberries(Ingredient):
  55. location = StrawberriesCrate
  56. needs_free_hands = True
  57. class ChoppedStrawberries(FinalProduct):
  58. location = ChoppingBoard
  59. requirements = [Strawberries]
  60. class Dough(Ingredient):
  61. location = DoughCrate
  62. needs_free_hands = True
  63. class Croissant(FinalProduct):
  64. requirements = [Dough]
  65. cooking_time = 10
  66. class ChoppedDough(Ingredient):
  67. requirements = [Dough]
  68. location = ChoppingBoard
  69. class RawTart(Ingredient):
  70. ingredients = [ChoppedDough, Blueberries]
  71. class Tart(FinalProduct):
  72. ingredients = [RawTart]
  73. cooking_time = 10
  74. class ExampleOrder():
  75. elements = [Dish, IceCream, ChoppedStrawberries, Croissant]
  76. def available(self):
  77. # special
  78. return []