import Toybox.Lang; import Toybox.WatchUi; import Toybox.Time; import Toybox.Timer; import Toybox.System; public enum enCard{ RED, YELLOW, GREEN } public enum enGoal{ PC, PS, FG } public enum enTeam{ HOME, AWAY } // public enum enState{ // PREGAME, // STARTGAME, // PREPLAY, // PLAY, // POSTPLAY, // BREAK, // POSTBREAK, // PLAYPAUSED, // GAMEOVER // } public enum enAction{ GOAL, CARD, QUIT } public enum enPeriod{ PLAY, BREAK } var gameDuration as Number?; var gameElapsed as Number?; var gamePeriod as Number?; class goal { private var _team as enTeam; private var _type as enGoal; private var _time as Number; private var _player as Number; private var _datetime as Number; function initialize(team as enTeam, type as enGoal, player as Number, time as Number) { _team = team; _type = type; _time = time; _player = player; _datetime = Time.now().value(); } function toDict() as Dictionary { return { "team" => _team, "type" => _type, "time" => _time, "player" => _player, "datetime" => _datetime }; } } class card { public var team as enTeam; public var card as enCard; public var player as Number; public var remaining as Number; public var isActive as Boolean; private var start as Number?; private var end as Number?; private var duration as Number?; private var _datetime as Number?; // public var display as String?; function initialize(tm as enTeam, cd as enCard, pl as Number, dn as Number, st as Number){ team = tm; card = cd; start = st; duration = dn * 60; remaining = duration; end = start + duration; player = pl; isActive = true; _datetime = Time.now().value(); // display = Lang.format("T:$1$-P:$2$-C:G",[_team, _player]); } // public function timeRemaining(el as Number) as Number{ // return end - el; // } public function dummy(q as Boolean) as Void{} public function update(el as Number) as Void{ remaining = end - el; if(end - el == 0){ // WatchUi.pushView(new menuConfirmationDelegate(Lang.format("Card: $1$ Over",[player.format("%02d")]), false), new ConfirmationDelegate(method(:dummy)), WatchUi.SLIDE_LEFT); System.println(Lang.format("Card: $1$ Over",[player.format("%02d")])); isActive = false; } } function toDict() as Dictionary { return { "team" => team, "start" => start, "end" => end, "card" => card, "player" => player, "duration" => duration, "datetime" => _datetime }; } } class match { function initialize() { } } class period{ // private var _timer; public var display as String?; public var type as enPeriod?; // public var isOver as Boolean = false; public var duration as Number?; public var remaining as Number?; // public var elapsed as Number = 0; // private var _acc as Number = 0; // private var _start as Number = 0; // private var _dur as Number = 0; function initialize(Display as String, Type as enPeriod, Duration as Number){//}, callBack as Method) { display = Display; type = Type; duration = Duration; remaining = Duration; // _timer = new Timer.Timer(); } // public function playPause(play as Boolean){ // if (play){ // _start = System.getTimer(); // _timer.start(method(:tick), 100, true); // } // else{ // _timer.stop(); // _acc += System.getTimer() - _start; // } // } public function elapsed(){ } }