merge all extra tables back into player for now
This commit is contained in:
parent
71ad4cada6
commit
9b01f6b96a
16 changed files with 66 additions and 579 deletions
|
|
@ -12,40 +12,28 @@ pub fn deal_hands(ctx: &ReducerContext, lobby_id: u32) {
|
|||
// FIXME rectify deal orders
|
||||
for mut player in players {
|
||||
let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13);
|
||||
tiles.sort();
|
||||
wall = ctx.db.wall().lobby_id().update(wall);
|
||||
let hand = ctx.db.hand().insert(Hand {
|
||||
id: 0,
|
||||
owner: PlayerOrBot::Player { id: player.id },
|
||||
sort: true,
|
||||
tiles,
|
||||
});
|
||||
player.hand_id = hand.id;
|
||||
tiles.sort();
|
||||
player.hand = tiles;
|
||||
ctx.db.player().id().update(player);
|
||||
}
|
||||
for mut bot in bots {
|
||||
let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13);
|
||||
tiles.sort();
|
||||
wall = ctx.db.wall().lobby_id().update(wall);
|
||||
let hand = ctx.db.hand().insert(Hand {
|
||||
id: 0,
|
||||
owner: PlayerOrBot::Bot { id: bot.id },
|
||||
sort: true,
|
||||
tiles,
|
||||
});
|
||||
bot.hand_id = hand.id;
|
||||
tiles.sort();
|
||||
bot.hand = tiles;
|
||||
ctx.db.bot().id().update(bot);
|
||||
}
|
||||
}
|
||||
|
||||
#[view(name = view_player_hand, public)]
|
||||
pub fn view_player_hand(ctx: &ViewContext) -> Option<Hand> {
|
||||
ctx.db
|
||||
.player()
|
||||
.identity()
|
||||
.find(ctx.sender)
|
||||
.map(|p| ctx.db.hand().id().find(p.hand_id))?
|
||||
}
|
||||
// #[view(name = view_player_hand, public)]
|
||||
// pub fn view_player_hand(ctx: &ViewContext) -> Option<Hand> {
|
||||
// ctx.db
|
||||
// .player()
|
||||
// .identity()
|
||||
// .find(ctx.sender)
|
||||
// .map(|p| ctx.db.hand().id().find(p.hand_id))?
|
||||
// }
|
||||
|
||||
// #[reducer]
|
||||
// pub fn sort_hand(ctx: &ReducerContext) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue