Coordinator v2

Dependencies:   NerfUSXbee PinDetect EthernetInterface JSON MFRC522 WebSocketClient mbed-rtos mbed

Committer:
Ismael Balafrej
Date:
Tue Apr 11 12:40:05 2017 -0400
Revision:
2:019d8848cf7e
Parent:
1:e1c5259b7d9a
Final version without allies/enemies

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ismael Balafrej 1:e1c5259b7d9a 1 #pragma once
Ismael Balafrej 1:e1c5259b7d9a 2 #include "ports.hpp"
Ismael Balafrej 1:e1c5259b7d9a 3 #include "ServerData.hpp"
Ismael Balafrej 1:e1c5259b7d9a 4 #include "GameCoordinator.hpp"
Ismael Balafrej 1:e1c5259b7d9a 5 #include <vector>
Ismael Balafrej 1:e1c5259b7d9a 6
Ismael Balafrej 1:e1c5259b7d9a 7 void dispatch_event_from_target(vector<uint8_t> data, int* address)
Ismael Balafrej 1:e1c5259b7d9a 8 {
Ismael Balafrej 2:019d8848cf7e 9 if (data[1]) {
Ismael Balafrej 2:019d8848cf7e 10 gameCoordinator.target_miss();
Ismael Balafrej 2:019d8848cf7e 11 } else {
Ismael Balafrej 2:019d8848cf7e 12 gameCoordinator.target_hit((data[2] << 8) | data[3]);
Ismael Balafrej 2:019d8848cf7e 13 }
Ismael Balafrej 1:e1c5259b7d9a 14 }
Ismael Balafrej 1:e1c5259b7d9a 15
Ismael Balafrej 1:e1c5259b7d9a 16 void dispatch_event_from_server(ServerEvent *event) {
Ismael Balafrej 1:e1c5259b7d9a 17 toPc("Event Name: %s", event->event);
Ismael Balafrej 1:e1c5259b7d9a 18 if (strcmp(event->event, "start_game") == 0)
Ismael Balafrej 1:e1c5259b7d9a 19 {
Ismael Balafrej 1:e1c5259b7d9a 20 gameCoordinator.start_game(&(event->data));
Ismael Balafrej 1:e1c5259b7d9a 21 }
Ismael Balafrej 1:e1c5259b7d9a 22 else if (strcmp(event->event, "request_report") == 0)
Ismael Balafrej 1:e1c5259b7d9a 23 {
Ismael Balafrej 1:e1c5259b7d9a 24 gameCoordinator.stop_game();
Ismael Balafrej 1:e1c5259b7d9a 25 }
Ismael Balafrej 1:e1c5259b7d9a 26 }