Also impl. use of Game Over with explicit winner/loser.
UnloadModel(scissors_model);
}
-void Renderer3D::update_state(const char *playerOne, const char *playerTwo,
- const char *currentPlayer, char first_first,
- char first_second, char first_third,
- char second_first, char second_second,
- char second_third, bool first_ready,
- bool second_ready, bool first_matchup_done,
- bool second_matchup_done, int pos, int prev_pos,
- bool gameover_called, bool matchup_started) {
+void Renderer3D::update_state(
+ const char *playerOne, const char *playerTwo, const char *currentPlayer,
+ char first_first, char first_second, char first_third, char second_first,
+ char second_second, char second_third, bool first_ready, bool second_ready,
+ bool first_matchup_done, bool second_matchup_done, int pos, int prev_pos,
+ bool gameover_called, bool matchup_started, const char *currentName) {
if (std::strcmp(playerOne, currentPlayer) == 0) {
flags.set(2);
flags.reset(3);
flags.set(3);
}
+ // DEBUG
+ //if (flags.test(2)) {
+ // std::cout << "Player one str is \"" << playerOne << "\"" << std::endl;
+ //} else {
+ // std::cout << "Player two str is \"" << playerTwo << "\"" << std::endl;
+ //}
+ //std::cout << "Name is \"" << currentName << std::endl;
+
flags.set(9, first_ready);
flags.set(10, second_ready);
flags.set(13, matchup_started);
char second_second, char second_third, bool first_ready,
bool second_ready, bool first_matchup_done,
bool second_matchup_done, int pos, int prev_pos,
- bool gameover_called, bool matchup_started) override;
+ bool gameover_called, bool matchup_started,
+ const char *currentName) override;
void do_update() override;
char second_third, bool first_ready,
bool second_ready, bool first_matchup_done,
bool second_matchup_done, int pos, int prev_pos,
- bool gameover_called, bool matchup_started) = 0;
+ bool gameover_called, bool matchup_started,
+ const char *currentName) = 0;
virtual void do_update() = 0;
char first_first, char first_second, char first_third, char second_first,
char second_second, char second_third, bool first_ready, bool second_ready,
bool first_matchup_done, bool second_matchup_done, int pos, int prev_pos,
- bool gameover_called, bool matchup_started) {
+ bool gameover_called, bool matchup_started, const char *currentName) {
((GameRenderer *)global_game_ptr)
->update_state(playerOne, playerTwo, currentPlayer, first_first,
first_second, first_third, second_first, second_second,
second_third, first_ready, second_ready,
first_matchup_done, second_matchup_done, pos, prev_pos,
- gameover_called, matchup_started);
+ gameover_called, matchup_started, currentName);
return 0;
}
function do_rune_init() {
Rune.initClient({
- visualUpdate: ({ newGame, yourPlayerId}) => {
+ visualUpdate: ({ newGame, yourPlayerId, players}) => {
const { player1, player2, first_choices, second_choices, ready, matchup_done, pos, prev_pos, gameover, gameover_called, matchup_started } = newGame;
function is_choices_filled(choices) {
return true;
}
+ let current_name = "spectator";
+ if (yourPlayerId !== undefined) {
+ current_name = players[yourPlayerId].displayName;
+ }
+
if (is_choices_filled(first_choices) && is_choices_filled(second_choices)) {
Module.ccall('game_visual_update',
'number',
'number', 'number', 'number',
'boolean', 'boolean',
'boolean', 'boolean',
- 'number', 'number', 'boolean', 'boolean'],
+ 'number', 'number', 'boolean', 'boolean',
+ 'string'],
[player1, player2,
yourPlayerId === undefined ? 'undefined' : yourPlayerId,
first_choices[0].charCodeAt(0),
second_choices[2].charCodeAt(0),
ready[0], ready[1],
matchup_done[0], matchup_done[1],
- pos, prev_pos, gameover_called, matchup_started]);
+ pos, prev_pos, gameover_called, matchup_started,
+ current_name]);
} else {
Module.ccall('game_visual_update',
'number',
'number', 'number', 'number',
'boolean', 'boolean',
'boolean', 'boolean',
- 'number', 'number', 'boolean', 'boolean'],
+ 'number', 'number', 'boolean', 'boolean',
+ 'string'],
[player1, player2,
yourPlayerId === undefined ? 'undefined' : yourPlayerId,
'?'.charCodeAt(0),
'?'.charCodeAt(0),
ready[0], ready[1],
matchup_done[0], matchup_done[1],
- pos, prev_pos, gameover_called, matchup_started]);
+ pos, prev_pos, gameover_called, matchup_started,
+ current_name]);
}
},
});
</style>
</head>
<body>
- <script src="https://cdn.jsdelivr.net/npm/rune-games-sdk@3/multiplayer.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/rune-games-sdk@4/multiplayer.js"></script>
<script src="logic.js" defer></script>
<script src="client.js" defer></script>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
game.matchup_started = false;
if (game.gameover) {
game.gameover_called = true;
- Rune.gameOver();
+ let p1_status = game.pos > 0 ? "WON" : "LOST";
+ let p2_status = game.pos < 0 ? "WON" : "LOST";
+ Rune.gameOver({
+ players: {
+ [game.player1]: p1_status,
+ [game.player2]: p2_status,
+ }
+ });
}
game.ready[0] = false;