smarter joinable algo

This commit is contained in:
ntr 2018-12-30 15:15:34 +11:00
parent 79f96a2ee0
commit 1f180402b3
4 changed files with 10 additions and 10 deletions

View File

@ -3,6 +3,7 @@ const Phaser = require('phaser');
const Header = require('./header'); const Header = require('./header');
const Menu = require('./menu'); const Menu = require('./menu');
const Combat = require('./combat'); const Combat = require('./combat');
const Missions = require('./missions');
function renderCryps() { function renderCryps() {
const config = { const config = {
@ -35,6 +36,11 @@ function renderCryps() {
if (!data || game.registry.get('inGame')) return false; if (!data || game.registry.get('inGame')) return false;
return game.scene.add('Combat', Combat, true); return game.scene.add('Combat', Combat, true);
} }
if (key === 'zone') {
return game.scene.add('Missions', Missions, true, data);
}
return true; return true;
} }

View File

@ -1,5 +1,4 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const Missions = require('./missions');
const { const {
TEXT, TEXT,
@ -123,7 +122,6 @@ class MenuGameList extends Phaser.Scene {
}); });
zones.on('pointerdown', () => { zones.on('pointerdown', () => {
this.scene.add('Missions', Missions, true);
return ws.sendAccountZone(); return ws.sendAccountZone();
}); });

View File

@ -15,8 +15,7 @@ class Missions extends Phaser.Scene {
this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png'); this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png');
} }
create() { create(zone) {
const zone = this.registry.get('zone');
if (!zone) return false; if (!zone) return false;
this.scene.manager.add('MissionControls', MissionControls, true); this.scene.manager.add('MissionControls', MissionControls, true);

View File

@ -208,11 +208,8 @@ pub fn node_joinable(graph: &ZoneGraph, target_index: NodeIndex) -> bool {
} }
} }
// now check the graph for connectedness let success_indices = graph.node_indices().filter(|i| {
// get all the nodes that have been successfully completed match graph.node_weight(*i) {
let mut filtered = graph.clone();
filtered.retain_nodes(|g, i| {
match g.node_weight(i) {
Some(encounter) => encounter.success, Some(encounter) => encounter.success,
None => panic!("no weight for {:?}", i), 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 // if a node is a neighbour of that graph
// and hasn't been attempted // and hasn't been attempted
// it is joinable // it is joinable
for i in filtered.node_indices() { for i in success_indices {
match graph.neighbors(i).find(|n| *n == target_index) { match graph.neighbors(i).find(|n| *n == target_index) {
Some(_n) => return true, Some(_n) => return true,
None => continue, None => continue,