Co-op campaign matches and command markers: mission relay, allied masters, temporary flags
This commit is contained in:
1 parent
dc22e27184
commit
5928acf7f6
12 files changed
+433
-27
No files matched your search
+54
-3
@@ -239,17 +239,29 @@ fn account_action(a: MenuAction, cloud: &mut Cloud, menu: &mut Menu, app: &mut A
|
||||
}
|
||||
MenuAction::MatchJoin(code) => app.client.join(&code),
|
||||
MenuAction::MatchCreate => app.client.create(&[0, 2, 3, 4], app.settings.map_w, app.settings.map_h, app.settings.difficulty),
|
||||
MenuAction::MatchCoopCreate(mission) => {
|
||||
let all = campaign::missions();
|
||||
if let Some(d) = all.get(mission) {
|
||||
app.client.create_coop(mission, &[0, 2, 3, 4], d.size.0, d.size.1, app.settings.difficulty);
|
||||
} else {
|
||||
menu.error = Some(i18n::tr("net.status_closed"));
|
||||
}
|
||||
}
|
||||
MenuAction::MatchTakeSide(side) => app.client.take_side(side),
|
||||
MenuAction::MatchReady(ready) => app.client.ready(ready),
|
||||
MenuAction::MatchStart => app.client.start(),
|
||||
MenuAction::MatchResume => app.client.resume(),
|
||||
MenuAction::MatchAbort => {
|
||||
app.client.abort();
|
||||
app.game.coop = false;
|
||||
app.match_mode = false;
|
||||
app.coop = false;
|
||||
}
|
||||
MenuAction::MatchLeave => {
|
||||
app.client.leave();
|
||||
app.game.coop = false;
|
||||
app.match_mode = false;
|
||||
app.coop = false;
|
||||
}
|
||||
MenuAction::MatchChat(text) => app.client.chat(&text, false),
|
||||
MenuAction::MatchEditField(i) => {
|
||||
@@ -380,6 +392,7 @@ struct App {
|
||||
client: MatchClient,
|
||||
ws_id: i32,
|
||||
match_mode: bool,
|
||||
coop: bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
@@ -402,6 +415,8 @@ impl App {
|
||||
store_settings(&self.settings);
|
||||
}
|
||||
self.game.hints = self.settings.hints;
|
||||
self.game.coop = false;
|
||||
self.coop = false;
|
||||
r3d.invalidate();
|
||||
menu.page = None;
|
||||
ui.show_help = false;
|
||||
@@ -482,12 +497,37 @@ impl App {
|
||||
self.ws_id = 0;
|
||||
}
|
||||
self.game.end_match();
|
||||
self.game.coop = false;
|
||||
self.match_mode = false;
|
||||
self.coop = false;
|
||||
self.client.on_disconnect();
|
||||
}
|
||||
|
||||
fn start_match_game(&mut self, info: StartInfo) -> bool {
|
||||
if info.map_w < 72 || info.map_h < 72 || !info.sides.contains(&0) {
|
||||
if !info.sides.contains(&0) {
|
||||
return false;
|
||||
}
|
||||
if let Some(mission) = info.mission {
|
||||
if !campaign::is_coop_mission(mission) {
|
||||
return false;
|
||||
}
|
||||
let local = info.local_side.unwrap_or(0);
|
||||
let mut game = campaign::start_coop_mission(mission, None);
|
||||
game.coop = true;
|
||||
if !game.start_match(&info.sides, local) {
|
||||
return false;
|
||||
}
|
||||
game.ai_difficulty = info.difficulty;
|
||||
game.hints = self.settings.hints;
|
||||
self.game = game;
|
||||
let (cx, cy) = self.game.map.core;
|
||||
self.cam = Cam::new(cx as f32 + 1.5, cy as f32 + 1.5);
|
||||
self.match_mode = true;
|
||||
self.coop = true;
|
||||
self.seed = info.seed.wrapping_mul(31) | 1;
|
||||
return true;
|
||||
}
|
||||
if info.map_w < 72 || info.map_h < 72 {
|
||||
return false;
|
||||
}
|
||||
self.game = Game::new(info.seed, info.map_w, info.map_h);
|
||||
@@ -495,12 +535,14 @@ impl App {
|
||||
if !self.game.start_match(&info.sides, local) {
|
||||
return false;
|
||||
}
|
||||
self.game.coop = false;
|
||||
self.game.ai_difficulty = info.difficulty;
|
||||
self.game.hints = self.settings.hints;
|
||||
self.game.init_fog();
|
||||
let (cx, cy) = self.game.map.core;
|
||||
self.cam = Cam::new(cx as f32 + 1.5, cy as f32 + 1.5);
|
||||
self.match_mode = true;
|
||||
self.coop = false;
|
||||
self.seed = info.seed.wrapping_mul(31) | 1;
|
||||
true
|
||||
}
|
||||
@@ -510,7 +552,11 @@ impl App {
|
||||
return;
|
||||
}
|
||||
for (_, cmds, ai) in self.client.take_turns() {
|
||||
self.game.sync_ai_sides(&ai, self.settings.difficulty);
|
||||
if self.coop {
|
||||
self.game.ai_sides.clear();
|
||||
} else {
|
||||
self.game.sync_ai_sides(&ai, self.settings.difficulty);
|
||||
}
|
||||
self.game.receive_turn(&cmds);
|
||||
}
|
||||
for (_, turn, sum) in self.client.take_checks() {
|
||||
@@ -554,7 +600,7 @@ async fn main() {
|
||||
let seed = (miniquad::date::now() * 1000.0) as u32 | 1;
|
||||
// behind the title menu: the endless bridge battle
|
||||
let (game, cam) = Game::new_demo(seed);
|
||||
let mut app = App { game, cam, settings, seed, status: None, recorded: false, client: MatchClient::new(), ws_id: 0, match_mode: false };
|
||||
let mut app = App { game, cam, settings, seed, status: None, recorded: false, client: MatchClient::new(), ws_id: 0, match_mode: false, coop: false };
|
||||
menu.progress = platform::storage_get(PROGRESS_KEY).and_then(|s| serde_json::from_str(&s).ok()).unwrap_or_default();
|
||||
app.game.hints = app.settings.hints;
|
||||
let mut inp = Input { ldown: None, rdown: None, rlast: (0.0, 0.0), rdrag: false, mlast: None, minimap_drag: false, tlast: None, touch_world: false, inspect: None };
|
||||
@@ -1029,6 +1075,8 @@ async fn main() {
|
||||
MenuAction::StartMission(i) => {
|
||||
(app.game, app.cam) = mission_game(i, &menu.progress);
|
||||
app.game.hints = app.settings.hints;
|
||||
app.game.coop = false;
|
||||
app.coop = false;
|
||||
app.recorded = false;
|
||||
menu.page = None;
|
||||
ui.log.clear();
|
||||
@@ -1048,6 +1096,7 @@ async fn main() {
|
||||
| MenuAction::OpenMatch
|
||||
| MenuAction::MatchJoin(..)
|
||||
| MenuAction::MatchCreate
|
||||
| MenuAction::MatchCoopCreate(..)
|
||||
| MenuAction::MatchTakeSide(..)
|
||||
| MenuAction::MatchReady(..)
|
||||
| MenuAction::MatchStart
|
||||
@@ -1090,6 +1139,8 @@ async fn main() {
|
||||
app.seed = next_seed(app.seed);
|
||||
(app.game, app.cam) = new_game(app.seed, &app.settings);
|
||||
app.game.hints = app.settings.hints;
|
||||
app.game.coop = false;
|
||||
app.coop = false;
|
||||
}
|
||||
// end of a mission: next mission (won) or try again (lost)
|
||||
UiAction::EndNext => {
|
||||
|
||||
Reference in new issue
Block a user