From 1f180402b3ca3f0f35e5bc9fdee19a45d024bdfc Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 30 Dec 2018 15:15:34 +1100 Subject: [PATCH] smarter joinable algo --- client/src/scenes/cryps.js | 6 ++++++ client/src/scenes/menu.game.list.js | 2 -- client/src/scenes/missions.js | 3 +-- server/src/zone.rs | 9 +++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/scenes/cryps.js b/client/src/scenes/cryps.js index 802b3fe8..f10e0921 100644 --- a/client/src/scenes/cryps.js +++ b/client/src/scenes/cryps.js @@ -3,6 +3,7 @@ const Phaser = require('phaser'); const Header = require('./header'); const Menu = require('./menu'); const Combat = require('./combat'); +const Missions = require('./missions'); function renderCryps() { const config = { @@ -35,6 +36,11 @@ function renderCryps() { if (!data || game.registry.get('inGame')) return false; return game.scene.add('Combat', Combat, true); } + + if (key === 'zone') { + return game.scene.add('Missions', Missions, true, data); + } + return true; } diff --git a/client/src/scenes/menu.game.list.js b/client/src/scenes/menu.game.list.js index 1ef465c2..47ba4705 100644 --- a/client/src/scenes/menu.game.list.js +++ b/client/src/scenes/menu.game.list.js @@ -1,5 +1,4 @@ const Phaser = require('phaser'); -const Missions = require('./missions'); const { TEXT, @@ -123,7 +122,6 @@ class MenuGameList extends Phaser.Scene { }); zones.on('pointerdown', () => { - this.scene.add('Missions', Missions, true); return ws.sendAccountZone(); }); diff --git a/client/src/scenes/missions.js b/client/src/scenes/missions.js index 4aff968a..5dde1f03 100644 --- a/client/src/scenes/missions.js +++ b/client/src/scenes/missions.js @@ -15,8 +15,7 @@ class Missions extends Phaser.Scene { this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png'); } - create() { - const zone = this.registry.get('zone'); + create(zone) { if (!zone) return false; this.scene.manager.add('MissionControls', MissionControls, true); diff --git a/server/src/zone.rs b/server/src/zone.rs index 59c5ac93..3c7c4ae1 100644 --- a/server/src/zone.rs +++ b/server/src/zone.rs @@ -208,11 +208,8 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool { } } - // now check the graph for connectedness - // get all the nodes that have been successfully completed - let mut filtered = graph.clone(); - filtered.retain_nodes(|g, i| { - match g.node_weight(i) { + let success_indices = graph.node_indices().filter(|i| { + match graph.node_weight(*i) { Some(encounter) => encounter.success, None => panic!("no weight for {:?}", i), } @@ -221,7 +218,7 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool { // if a node is a neighbour of that graph // and hasn't been attempted // it is joinable - for i in filtered.node_indices() { + for i in success_indices { match graph.neighbors(i).find(|n| *n == target_index) { Some(_n) => return true, None => continue,