Commit 9d3496ce authored by gem2578's avatar gem2578 Committed by Marcus M. Scheunemann

Object Type is now a enum

parent 2f9e85f9
......@@ -3,13 +3,13 @@ from model.side import Side
class CupObject():
def __init__(self, type, pos, side=None):
self.type = type
def __init__(self, obj_type, pos, side=None):
self.type = obj_type
self.pos = Vector2(pos)
self.side = side
def __repr__(self):
if self.side is not None:
return self.type + self.side.value
return self.type.value + " " + self.side.value
else:
return self.type
return self.type.value
from enum import Enum
class ObjectType(Enum):
BALL = "Ball"
GOAL = "Goal"
PLAYER = "Player"
import pygame
import sprite.round_sprite as rs
from model.side import Side
from model.object_type import ObjectType
from model.cup_object import CupObject
class Player(rs.Round):
......@@ -50,12 +51,12 @@ class Brain():
self.side = side
def setup(self, goals):
self.self_goal = CupObject("goal", goals.get(self.side).rect.center, self.side)
self.self_goal = CupObject(ObjectType.GOAL, goals.get(self.side).rect.center, self.side)
other_side = self.side.other()
self.other_goal = CupObject("goal", goals.get(other_side).rect.center, Side.other(other_side))
self.other_goal = CupObject(ObjectType.GOAL, goals.get(other_side).rect.center, Side.other(other_side))
def pre_action(self, body):
self.ball = CupObject("ball", body.ball.rect().center)
self.ball = CupObject(ObjectType.BALL, body.ball.rect().center)
self.pos = pygame.math.Vector2(body.rect.center)
body.can_kick = self.pos.distance_to(self.ball.pos) < 30
self.can_kick = body.can_kick
......@@ -64,11 +65,11 @@ class Brain():
self.self_team = []
for player in body.self_team:
if(player != body):
self.self_team.append(CupObject("player", player.rect.center, self.side))
self.self_team.append(CupObject(ObjectType.PLAYER, player.rect.center, self.side))
self.other_team = []
for player in body.other_team:
self.other_team.append(CupObject("player", player.rect.center, self.side.other()))
self.other_team.append(CupObject(ObjectType.PLAYER, player.rect.center, self.side.other()))
def sorted_object(self):
objects = [self.ball, self.self_goal, self.other_goal] + self.self_team + self.other_team
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment