Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.enst.pact43.model;
- import fr.enst.pact43.model.events.GoalEvent
- import fr.enst.pact43.rules.RuleSet
- class GameManager(val babyFoot: BabyFoot) {
- val state = new BabyFootState();
- val rs = new RuleSet();
- val startTime = System.currentTimeMillis;
- var time = startTime
- def weirdTime =
- if(internalTime == startTime) System.currentTimeMillis - startTime
- else time
- val goals = new TimedMap<GoalEvent>();
- def getScore(time: Long, team: Team) = {
- goals.
- takeWhile( _.getTime <= time).
- count( _.getScoringTeam == team )
- }
- /** team : the team who scored the goal
- * return value : whether the goal was accepted */
- def signalGoal(team: Team) = signalGoal(weirdTime, timeteam);
- /** team : the team who scored the goal
- * return value : whether the goal was accepted */
- def signalGoal(time: Long, team: Team) = {
- val goal = new GoalEvent(babyFoot, time, team);
- if(!goal.isValid(rs)) {
- false
- } else {
- goals.put(time, goal)
- true
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement