Advertisement
philRG

Code Keeper (draft)

Dec 17th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.05 KB | None | 0 0
  1. from collections import namedtuple
  2.  
  3. import sys
  4. from enum import Enum
  5. from typing import Tuple, List, Optional
  6.  
  7.  
  8. def idebug(*args):
  9.     # return
  10.     print(*args, file=sys.stderr, flush=True)
  11.  
  12.  
  13. def debug(*args):
  14.     # return
  15.     print(*args, file=sys.stderr, flush=True)
  16.  
  17.  
  18. class WeaponDamage(Enum):
  19.     SWORD = 10
  20.     HAMMER = 6
  21.     SCYTHE = 7
  22.     BOW = 8
  23.  
  24.  
  25. class MonsterType(Enum):
  26.     BOX = 7
  27.     SKEL = 8
  28.     GARG = 9
  29.     ORC = 10
  30.     VAMP = 11
  31.  
  32.  
  33. class Position:
  34.     def __init__(self):
  35.         self.x, self.y = x, y
  36.  
  37.     def __repr__(self):
  38.         return f'{self.x} {self.y}'
  39.  
  40.  
  41. class Monster:
  42.     def __init__(self, x, y, health, etype):
  43.         self.pos = Position(x, y)
  44.         self.health = health
  45.         self.type = MonsterType(etype)
  46.         self.view_range, self.attack_range, self.damage = monsters_caract[self.type]
  47.  
  48.  
  49. class Hero:
  50.     def __init__(self, x, y, health, score, charges_hammer, charges_scythe, charges_bow):
  51.         self.pos = Position(x, y)
  52.         self.health = health
  53.         self.score = score
  54.         self.chargesHammer = charges_hammer
  55.         self.charges_scythe = charges_scythe
  56.         self.charges_bow = charges_bow
  57.         self.view_range = 3
  58.  
  59.     def __repr__(self):
  60.         return f'{self.pos} {self.health} {self.score} {self.chargesHammer} {self.charges_scythe} {self.charges_bow}'
  61.  
  62.  
  63. # Make the hero reach the exit of the maze alive.
  64.  
  65. Caract = namedtuple('MonsterCarac', ['view_range', 'attack_range', 'damage'])
  66.  
  67. monsters_caract = {}
  68. for monster_type in enumerate(MonsterType):
  69.     match monster_type:
  70.         case MonsterType.BOX:
  71.             monsters_caract[monster_type] = Caract(0, 0, 0)
  72.         case MonsterType.SKEL:
  73.             monsters_caract[monster_type] = Caract(1, 1, 1)
  74.         case MonsterType.GARG:
  75.             monsters_caract[monster_type] = Caract(2, 1, 2)
  76.         case MonsterType.ORC:
  77.             monsters_caract[monster_type] = Caract(3, 1, 3)
  78.  
  79.  
  80. # game loop
  81. while True:
  82.     # x: x position of the hero
  83.     # y: y position of the hero
  84.     # health: current health points
  85.     # score: current score
  86.     # charges_hammer: how many times the hammer can be used
  87.     # charges_scythe: how many times the scythe can be used
  88.     # charges_bow: how many times the bow can be used
  89.     x, y, health, score, charges_hammer, charges_scythe, charges_bow = [int(i) for i in input().split()]
  90.     idebug(x, y, health, score, charges_hammer, charges_scythe, charges_bow)
  91.  
  92.     visible_entities = int(input())  # the number of visible entities
  93.     idebug(visible_entities)
  94.     for i in range(visible_entities):
  95.         # ex: x position of the entity
  96.         # ey: y position of the entity
  97.         # etype: the type of the entity
  98.         # evalue: value associated with the entity
  99.         ex, ey, etype, evalue = [int(j) for j in input().split()]
  100.         idebug(ex, ey, etype, evalue)
  101.  
  102.     # Write an action using print
  103.     # To debug: print("Debug messages...", file=sys.stderr, flush=True)
  104.  
  105.     # MOVE x y [message] | ATTACK weapon x y [message]
  106.     print("MOVE 6 8 Let's go!")
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement