Closed CraigTheKiwi closed 7 years ago
@sumnerfit Is this ready for testing/merging?
Sorry, Yes please
Cool - will try getting it done over lunchtime, other wise will be this evening.
Somehow got stuck -- just trying to see if I can replicate
debug: SM#0: game_turn: data follows:
debug: SM#0: object data =
{ data_type: 'force_finish_turn',
player:
{ id: 1,
name: 'Fred',
game_id: 0,
game_name: undefined,
winner: false,
connected: true,
turn_complete: false,
turn_data: { data_type: 'turn_complete', player_id: 1, actions: [] },
colour: 'red',
used_dev_card: false,
recent_purchases: [],
score:
{ total_points: 2,
victory_points: 0,
road_length: 1,
settlements: 2,
cities: 0,
longest_road: false,
largest_army: false },
actions: [],
cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
inter_trade:
{ wants_trade: false,
trade_cards: [Object],
wants_cards: [Object] },
round_distribution_cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
trading:
{ sheep: false,
ore: false,
lumber: false,
brick: false,
grain: false,
three: false } } }
info: SM#0: Tim invoked game_update
debug: SM#0: round #7
debug: SM#0: ticked play state : initiated by Tim
info: SM#0: Requested action is turn_complete
debug: SM#0: in "play" state
info: SM#0: Fred invoked game_update
debug: SM#0: round #7
debug: SM#0: ticked play state : initiated by Fred
info: SM#0: Requested action is turn_complete
debug: Timer: round timer stopping
debug: Server side timer stopped.
debug: SM#0: validate_player_builds function called.
debug: SM#0: --------------------------- Round Number 8 ---------------------------
debug: Players have same length road
debug: SM#0: update_game: sending to send data to player 0
debug: SM#0: update_game: data follows:
debug: SM#0: update_game: sending to send data to player 1
debug: SM#0: update_game: data follows:
debug: SM#0: game_turn: sending to send data to player 0
debug: SM#0: game_turn: data follows:
debug: SM#0: object data =
Data_package {
turn_type: '',
player:
{ id: 0,
name: 'Tim',
game_id: 0,
game_name: 'Tim\'s Game',
winner: false,
connected: true,
turn_complete: false,
turn_data: { data_type: 'turn_complete', player_id: 0, actions: [] },
colour: 'purple',
used_dev_card: false,
recent_purchases: [],
score:
{ total_points: 2,
victory_points: 0,
road_length: 1,
settlements: 2,
cities: 0,
longest_road: false,
largest_army: false },
actions: [],
cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
inter_trade:
{ wants_trade: false,
trade_cards: [Object],
wants_cards: [Object] },
round_distribution_cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
trading:
{ sheep: false,
ore: false,
lumber: false,
brick: false,
grain: false,
three: false } },
game_state: null,
data_type: 'round_turn' }
debug: Timer: monopoly timer starting
debug: Server side monopoly timer set to :30 seconds
debug: SM#0: in "play" state
debug: Player hasnt finished monopoly turn
debug: SM#0: Broadcasting event: game_turn
debug: Timer: monopoly timer stopping
debug: Server side monopoly timer stopped.
debug: Timer: round timer starting
debug: Server side round timer set to :80 seconds
debug: SM#0: Broadcasting event: timestamp
info: SM#0: Tim invoked game_update
debug: SM#0: round #8
debug: SM#0: ticked play state : initiated by Tim
info: SM#0: Requested action is turn_complete
debug: SM#0: in "play" state
debug: Players havent finished their turn
debug: SM#0: game_turn: sending to send data to player 1
debug: SM#0: game_turn: data follows:
debug: SM#0: object data =
{ data_type: 'force_finish_turn',
player:
{ id: 1,
name: 'Fred',
game_id: 0,
game_name: undefined,
winner: false,
connected: true,
turn_complete: false,
turn_data: { data_type: 'turn_complete', player_id: 1, actions: [] },
colour: 'red',
used_dev_card: false,
recent_purchases: [],
score:
{ total_points: 2,
victory_points: 0,
road_length: 1,
settlements: 2,
cities: 0,
longest_road: false,
largest_army: false },
actions: [],
cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
inter_trade:
{ wants_trade: false,
trade_cards: [Object],
wants_cards: [Object] },
round_distribution_cards:
Cards {
resource_cards: [Object],
dev_cards: [Object],
victory_point_cards: [Object] },
trading:
{ sheep: false,
ore: false,
lumber: false,
brick: false,
grain: false,
three: false } } }```
Looks good! Merging now.
Basic concept: On round start or player displaying monopoly, server creates a timestamp + round/monopoly time and starts a setTimeout. Server sends that timestamp to client, client starts the timer animation with that timestamp as the endpoint (has no actual timer itself). When round time expires, each player gets a request to finish their turn. When monopoly time expires, monopoly owner gets a notification to close window, everyone else gets start turn and animation for round begins.
To test: