Skip to content

Commit

Permalink
Fixed interpretation of BattleField coordinates. Implemened monitorin…
Browse files Browse the repository at this point in the history
…g angular service () for repetative service calls. Reimplemented 'BattleService.time_left()' calls using service to avoid context errors. Reimplemented 'BattleService.initiali_state()' call to avoid context errors. Done with preparations for implementing 'BattleService.processAction()' and related methods.
  • Loading branch information
juraj committed Jun 18, 2013
1 parent 29264de commit 22e7989
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 139 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,43 @@ And then you can inspect the initialized view-model's battleField object with:

```javascript
bt.services.execute('BattleService', function(service) {
service.getUsername(
service.calls.getUsername(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.timeLeft(
service.calls.timeLeft(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.initialState(
service.calls.initialState(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.lastResult(
service.calls.lastResult(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.getStates(
service.calls.getStates(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.getLastState(
service.calls.getLastState(
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
);
});
bt.services.execute('BattleService', function(service) {
service.processAction(
service.calls.processAction(
'action type',
function(data) { console.log("Success:"); console.log(data); },
function(data) { console.log("Fail:"); console.log(data); }
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<script type="text/javascript" src="res/js/3rd_party/angular.115.js"></script>
<!-- Not yet needed: <script type="text/javascript" src="res/js/3rd_party/angular_resource.115.js"></script> -->
<script type="text/javascript" src="res/js/3rd_party/angular_jsonrpc.js"></script>
<script type="text/javascript" src="res/js/3rd_party/angular_interval.js"></script>
<!-- Not yet needed: <script type="text/javascript" src="res/js/3rd_party/jquery.202.js"></script> -->
<!-- BT: JS inclusions -->
<script type="text/javascript" src="res/js/bt_init.js"></script>
Expand Down
20 changes: 17 additions & 3 deletions res/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,35 @@ div.menu {
/* Battle view markup (TEMP)
* ---------------------------------------------------------------------------------------------------------------------- */

div.timers {
div.toolbox {
float: right;
}

div.toolbox div.timers {
clear: right;
float: right;
margin: 4px 10px 4px 10px;
padding: 4px;
border: 1px solid #444444;
}
div.timers div.timer {
div.toolbox div.timers div.timer {
color: #990000;
}

div.toolbox div.selected {
clear: right;
float: right;
margin: 4px 10px 4px 10px;
padding: 4px;
border: 1px solid #444444;
}


div.grid {
float: left;
}
div.grid div.grid_row {
clear: both;
clear: left;
float: left;
}
div.grid div.grid_row:nth-child(odd) {
Expand Down
44 changes: 44 additions & 0 deletions res/js/3rd_party/angular_interval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
angular.module('angular-interval', []);
//
// Interval for angular js.
//
var interval = angular.module('angular-interval', []).factory("$interval", function($timeout) {

// Factory base reference
var intervalBase = this;

// Sets a new interval action
this.set = function(name, fn, interval) {
intervalBase._intervals[name] = {
name : name,
fn : fn,
interval : interval,
run : true
};
};
// Clears an interval action
this.clear = function(name) {
delete intervalBase._intervals[name];
}
// Starts an interval action
this.start = function(name, starting) {
if (intervalBase._intervals[name]) {
if (!starting) intervalBase._intervals[name].run = true;
if (intervalBase._intervals[name].run) {
$timeout(intervalBase._intervals[name].fn, intervalBase._intervals[name].interval)
.then( function() { intervalBase.start(name, true); } );
}
}
}
// Stops an interval action
this.stop = function(name) {
intervalBase._intervals[name].run = false;
}

// Holds references to interval actions
this._intervals = { };

// Return $interval service
return this;

});
6 changes: 3 additions & 3 deletions res/js/3rd_party/angular_jsonrpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module('angular-json-rpc', []);
// json rpc for angular js. JSON-RPC-2.0 compatible.
// spec - http://www.jsonrpc.org/specification
//
var jsonRpc = angular.module('angular-json-rpc', []).factory("jsonRpc", ['$http', function($http) {
var jsonRpc = angular.module('angular-json-rpc', []).factory("$jsonRpc", ['$http', function($http) {
this.version = "2.0";

var jsonRpcBase = this;
Expand Down Expand Up @@ -61,9 +61,9 @@ var jsonRpc = angular.module('angular-json-rpc', []).factory("jsonRpc", ['$http'
//
// json-recp request method definition
//
this.method = function(name, parameters, onSuccess, onFail, onError) {
this.method = function(name) {
// Define method call
var methodCall = function(onSuccess, onFail, onError) {
var methodCall = function(parameters, onSuccess, onFail, onError) {
jsonRpcBase.request(
name,
{ params : parameters },
Expand Down
2 changes: 1 addition & 1 deletion res/js/bt_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ bt.config.urls = {
bt.config.poling.minimalIntervalBetweenPolls = 2000;

// Set debugging options
bt.debugging.events.publishToConsole = true;
bt.debugging.events.publishToConsole = false;
bt.debugging.model.verifyModelConstructors = true;
Loading

0 comments on commit 22e7989

Please sign in to comment.