Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
feat(game): added suicide button
Browse files Browse the repository at this point in the history
closes #20
  • Loading branch information
Rabrennie committed Dec 3, 2015
1 parent 65b26b5 commit 3265946
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/jade/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ html(ng-app="Roguathia", ng-controller="Root")
uib-tab(heading="Log")
log

uib-tab(heading="Options", ng-if="false")
div options
uib-tab(heading="Options")
div(ng-controller="Options", ng-include="'options-tab'")

script(src="js/lib.min.js")
script(src="js/main.min.js")
script(src="js/main.min.js")
7 changes: 7 additions & 0 deletions src/jade/templates/options-tab.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
script(type="text/ng-template", id="options-tab")
.options-container(fill-height, offset="40")
.row.margin-bottom-20.margin-top-20
.col-xs-6
span Seppuku
a.btn.btn-link.pull-right(ng-mouseover='getCurrentSpKp()' ng-click='seppuku("lel")' uib-tooltip="You will gain: {{spEarned}} SP, {{kpEarned}} KP", tooltip-placement="right", tooltip-append-to-body="true") DO IT

20 changes: 20 additions & 0 deletions src/js/angular/controllers/Options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import module from '../module';
import GameState from '../../rogue/init/gamestate';
import _ from 'lodash';

module.controller('Options', ($scope) => {

$scope.seppuku = () => {
_.each(GameState.players, p => {
if (!p.hp.atMin()) {
p.die({ name:'Seppuku' });
}
});
};

$scope.getCurrentSpKp = () => {
$scope.spEarned = GameState.spEarned;
$scope.kpEarned = GameState.kpEarned;
};

});
11 changes: 7 additions & 4 deletions src/js/angular/controllers/Party.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash';
import module from '../module';
import GameState from '../../rogue/init/gamestate';

module.controller('Party', ($scope, $uibModal) => {
module.controller('Party', ($scope, $uibModal, $timeout) => {

$scope.inventoryOffset = () => 60 + document.getElementsByClassName('player-block')[0].offsetHeight;

Expand All @@ -21,8 +21,11 @@ module.controller('Party', ($scope, $uibModal) => {
};

GameState.on('redraw', () => {
$scope.players = GameState.players;
$scope.$apply();

$timeout(function() {
$scope.players = GameState.players;
});

});
});

Expand Down Expand Up @@ -80,4 +83,4 @@ module.controller('PartyMemberEdit', ($scope, $uibModalInstance, TemplateDataMan
{ key: 'Explore Dungeon', val: undefined },
{ key: 'Wander', val: 'Wander' }
];
});
});
14 changes: 8 additions & 6 deletions src/js/angular/controllers/Upgrades.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.filter('visibleUpgrades', (CurrencyDataManager, UpgradeDataManager) => {
};
});

module.controller('Upgrades', ($scope, $localStorage, CurrencyDataManager, UpgradeDataManager, TemplateDataManager) => {
module.controller('Upgrades', ($scope, $localStorage,$timeout, CurrencyDataManager, UpgradeDataManager, TemplateDataManager) => {

$scope.upgrades = Upgrades;
$scope.upgradeDataManager = UpgradeDataManager;
Expand Down Expand Up @@ -70,13 +70,15 @@ module.controller('Upgrades', ($scope, $localStorage, CurrencyDataManager, Upgra
});

GameState.on('gameover', () => {
getCurrencyFrom(GameState);

$localStorage.saveStateCache = null;
$timeout(function() {
getCurrencyFrom(GameState);

$localStorage.saveStateCache = null;

rebuildUpgrades();
rebuildUpgrades();
});

$scope.$apply();
});

});
});
4 changes: 3 additions & 1 deletion src/js/angular/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import './controllers/Root';
import './controllers/Party';
import './controllers/Log';
import './controllers/Dungeon';
import './controllers/Options';
import './controllers/Upgrades';


import './services/UpgradeDataManager';
import './services/CurrencyDataManager';
import './services/TemplateDataManager';

import './directives/tabs/log-tab';

import './directives/fill-height';
import './directives/fill-height';

0 comments on commit 3265946

Please sign in to comment.