Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b402e2a
servers are stored in an object
sirpython Aug 17, 2015
fbcbc75
now server is stored with information like user count and latency
sirpython Aug 17, 2015
a700300
changed html to fit new server storage, setup table for server inform…
sirpython Aug 17, 2015
57707f6
added <b> around column names to make more prominent
sirpython Aug 17, 2015
9635c92
added updateStats function
sirpython Aug 17, 2015
4bc0203
fixed typo in server map, added checking in updateStats so there is n…
sirpython Aug 17, 2015
2dfe989
added refresh button
sirpython Aug 17, 2015
f9456d1
Added images for Chinese cardset
Aug 29, 2015
653f4e4
Merge branch 'card-images' into develop
Zomis Aug 29, 2015
4dcb224
player-specific action buttons checks the player to determine visibility
Zomis Aug 29, 2015
e933945
fix a problem in `moveCard` (ZoneChangeMessage handler) when source z…
Zomis Aug 29, 2015
75746d0
Added mythos/hindu/ images
Aug 30, 2015
a0c5377
Merge branch 'card-images' of https://github.com/Cardshifter/HTML-Cli…
Aug 30, 2015
65478a5
Merge remote-tracking branch 'origin/card-images' into card-images
Aug 30, 2015
b3fb3df
added ServerInfos class
sirpython Aug 30, 2015
6b84fe4
fixed issues with cards not found when UpdateMessage is sent before C…
Zomis Aug 30, 2015
680e8e4
fixed bug where the final server would not be recognized
sirpython Aug 30, 2015
b59aba9
now gets server information, except for users online count
sirpython Aug 31, 2015
6591d23
added ftp-deploy to the dependencies
sirpython Sep 1, 2015
83012cf
added refresh button to server stats
sirpython Sep 1, 2015
5544c6c
Revert "added refresh button to server stats"
sirpython Sep 1, 2015
3159b47
Revert "Revert "added refresh button to server stats""
sirpython Sep 1, 2015
1f5ca3e
added delay for refresh button
sirpython Sep 1, 2015
91b0a58
Add mythos/greek image files
Sep 5, 2015
60646a6
Cropped bear.jpg correctly
Sep 5, 2015
4998a8d
images/cards/mythos/common
Sep 5, 2015
3664d72
merge card-images into develop
Sep 5, 2015
8148b24
CardshifterServerAPI.init is now called by passing anonymous function…
sirpython Sep 6, 2015
cee375b
working on $scope.refreshing
sirpython Sep 6, 2015
8ad2e84
cleaned up code
sirpython Sep 6, 2015
a2130a0
fixed issue where refresh button was not becoming disabled
sirpython Sep 6, 2015
1aa024f
fixed problem where refreshing created blank users
sirpython Sep 6, 2015
a03738f
fixed naming
sirpython Sep 6, 2015
e676e99
added "Refreshing..." message so user is not confused by delay
sirpython Sep 6, 2015
1626fdd
added documentation
sirpython Sep 6, 2015
a9bd789
now grabs user count
sirpython Sep 9, 2015
a3b74eb
corrected checking for a blank eventTypes array
sirpython Sep 9, 2015
54e18bf
removed annoying console.log
sirpython Sep 9, 2015
3bdbecc
removed removal of one user
sirpython Sep 10, 2015
4414b47
changed <td><b> to <th>, added more columns
sirpython Sep 10, 2015
da7a2b0
now grabs mod amount, game amount, and AI amount for server stats
sirpython Sep 10, 2015
1355128
Merge pull request #98 from Cardshifter/develop
sirpython Sep 12, 2015
5ada912
WIP: Create deploy script
jacwah Sep 12, 2015
77c1367
Add FTP upload functionality to deploy script
jacwah Sep 13, 2015
b0a5c1c
WIP: Post to Duga on deploy
jacwah Sep 13, 2015
f09daa5
Use request library instead of raw http in deploy
jacwah Sep 13, 2015
0b3b8a2
Copy all files to temp dir before deploying
jacwah Sep 13, 2015
1b97ff0
Disable Duga deploy post if no api key
jacwah Sep 13, 2015
d9d505b
Clean up deploy script
jacwah Sep 13, 2015
8f5713c
Document how to use deploy script
jacwah Sep 13, 2015
695e220
Fix comment typo
jacwah Sep 13, 2015
8c3844d
Use promises for setupFiles in deploy script
jacwah Sep 13, 2015
df7320a
Use promises for FTP deployment
jacwah Sep 13, 2015
2dc5851
Adjust deploy script logging
jacwah Sep 13, 2015
1d20e63
Use promises for Duga request in deploy script
jacwah Sep 13, 2015
072df2e
Clean up deploy script
jacwah Sep 13, 2015
d477ed4
messages sent by the user are now highlighted yellow
sirpython Sep 13, 2015
4a48dc0
there is now a delay for sending chat messages with the enter key
sirpython Sep 13, 2015
c85b77b
Refactor deploy postToChat
jacwah Sep 14, 2015
11f0234
removed !important from css rule
sirpython Sep 14, 2015
ed20fcb
Clean up deploy script
jacwah Sep 14, 2015
44e5e77
Add correct FTP address for deploy
jacwah Sep 14, 2015
e96a463
changed colors for chat messages
sirpython Sep 14, 2015
c5f4041
only tries to display "from" in a chat message if it exists, cleaned …
sirpython Sep 14, 2015
a1b9848
Merge pull request #104 from Cardshifter/develop
sirpython Sep 18, 2015
5824c29
includes and creates the errorCreator service
sirpython Sep 18, 2015
66332b3
basic error message modal html
sirpython Sep 18, 2015
b697eec
a basic error creator service
sirpython Sep 18, 2015
b7bdd79
fixed up the error creator; it now works!
sirpython Sep 20, 2015
4692009
added ErrorCreator.creates where there were console.logs
sirpython Sep 20, 2015
6693357
added listening for ServerErrorMessage
sirpython Sep 20, 2015
7275503
Use bluebird promises in deploy script
jacwah Sep 20, 2015
fbc7b7f
Merge pull request #103 from Cardshifter/deploy-script
Zomis Sep 20, 2015
897c597
Merge pull request #97
Zomis Sep 20, 2015
9c92ad5
Include stack trace in errors in deploy script
jacwah Sep 20, 2015
bb55275
Log deployed files
jacwah Sep 20, 2015
5520597
Merge branch 'deploy-script' into develop
jacwah Sep 20, 2015
c87da4d
the server stats are now loaded/refreshed on page load
sirpython Sep 20, 2015
53a1338
Merge pull request #97 Server stats
Zomis Sep 20, 2015
3f582ea
changed how setMessageListener works
sirpython Sep 23, 2015
2a4086a
all the controllers now use CardshifterServerAPI.setMessageListener c…
sirpython Sep 23, 2015
6754fdb
chat errors messages now use ErrorCreator instead
sirpython Sep 26, 2015
829baa2
all sent and received messages can now be seen via the browser console
sirpython Sep 26, 2015
3a52908
Merge branch 'errors' of https://github.com/Cardshifter/HTML-Client i…
sirpython Sep 26, 2015
6dec038
fixed ErrorCreator.create call
sirpython Sep 26, 2015
c602ba9
removed "Client Error:" from error message
sirpython Sep 27, 2015
f49738c
removed some nesting and unnecessary code
sirpython Sep 27, 2015
28b79a9
Improve gitignore
jacwah Sep 29, 2015
54161d2
Fix protocol regex
jacwah Sep 29, 2015
469284e
Display player resources as 'Max mana'
jacwah Sep 29, 2015
e555f0e
Display as 'Cards' instead of 'CARDS'
jacwah Sep 29, 2015
4f6041c
Rename filter to 'formatResourceName'
jacwah Oct 1, 2015
5b2b61f
Merge pull request #112 from Cardshifter/small-fix
jacwah Oct 1, 2015
e317772
added debug dependency
sirpython Oct 16, 2015
58e089e
replaced console.logs with debugs
sirpython Oct 16, 2015
6cd2e4c
correctly injects debug
sirpython Oct 16, 2015
eca1e61
api is now a factory
sirpython Oct 17, 2015
3d5bb4c
removed last console.log
sirpython Oct 17, 2015
32082f4
now displays api information in the browser console
sirpython Oct 17, 2015
6caa7c3
Merge errors into develop
Mar 17, 2016
123164f
Merge errors into develop
Mar 17, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,7 @@ node_modules
.lock-wscript

### Webpack
dist/
dist/

### OS X files
/**/.DS_Store
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "webpack --config webpack.config.js --optimize-minimize --devtool source-map",
"develop": "webpack-dev-server",
"test": "karma start"
"test": "karma start",
"deploy": "node scripts/deploy.js"
},
"repository": {
"type": "git",
Expand All @@ -24,7 +25,11 @@
"homepage": "https://github.com/Cardshifter/HTML-Client#readme",
"private": true,
"devDependencies": {
"bluebird": "^2.10.0",
"css-loader": "^0.15.6",
"debug": "^2.2.0",
"ftp-deploy": "^1.0.0",
"temp": "^0.8.3",
"html-loader": "^0.3.0",
"jasmine-core": "^2.3.4",
"karma": "^0.13.8",
Expand All @@ -33,14 +38,16 @@
"karma-webpack": "^1.7.0",
"ng-annotate-webpack-plugin": "^0.1.2",
"phantomjs": "^1.9.17",
"recursive-copy": "^1.0.10",
"request-promise": "^0.4.3",
"style-loader": "^0.12.3",
"webpack": "^1.11.0",
"webpack-dev-server": "^1.10.1"
},
"dependencies": {
"angular": "1.4.3",
"angular-route": "1.4.3",
"angular-animate": "1.4.3",
"angular-bootstrap-npm": "0.13.3",
"angular-animate": "1.4.3"
"angular-route": "1.4.3"
}
}
130 changes: 130 additions & 0 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/* Deploy the client to play.cardshifter.com
*
* How to use:
* 1. Build the project and make sure that everything is in order.
* 2. Set up environment variables (see below).
* 3. Run `npm run deploy`.
* 4. Profit!
*
* Environment variables used:
* - DEPLOY_FTP_USERNAME: Username used to log in through FTP.
* - DEPLOY_FTP_PASSWORD: Password used to log in through FTP.
* - DEPLOY_DUGA_KEY: Duga API key. If not set the chat bot post is skipped.
*/
'use strict';

var copy = require('recursive-copy');
var FtpDeploy = require('ftp-deploy');
var path = require('path');
var Promise = require('bluebird');
var request = require('request-promise');
var temp = require('temp').track();

var deployAddress = "play.cardshifter.com";

function ftpConfig(local, remote) {
return {
username: process.env.DEPLOY_FTP_USERNAME,
password: process.env.DEPLOY_FTP_PASSWORD,
host: deployAddress,
port: 21, // Standard FTP port
localRoot: local,
remoteRoot: remote
};
};

var chatBotRequest = {
// http://chat.stackexchange.com/rooms/info/16134/cardshifter-tcg
roomId: 16134,
apiKey: process.env.DEPLOY_DUGA_KEY,
text: "New web client version uploaded to [" + deployAddress + "](http://" + deployAddress +"/)."
};

var chatBotConfig = {
url: "http://stats.zomis.net/GithubHookSEChatService/bot/jsonPost",
method: "POST",
headers: {
"Content-Type": "application/json"
}
}

function postToChat(config, botRequest) {
return new Promise(function(resolve, reject) {
var json = JSON.stringify(botRequest, ["apiKey", "roomId", "text"]);
config.headers["Content-Length"] = json.length;
config.body = json;

request(config)
.then(function(body) {
resolve(body);
})
});
}

function setupFiles() {
// ftp-deploy doesn't handle uploading from multiple directories well
return new Promise(function(resolve, reject) {
temp.mkdir("cardshifter-deploy", function (err, tempDir) {
if (err) {
reject(err);
}

Promise.all([
copy(path.join(__dirname, "..", "www"), tempDir),
copy(path.join(__dirname, "..", "dist"), path.join(tempDir, "assets"))
])
.then(function() {
resolve(tempDir);
})
.catch(function(err) {
reject(err);
});
});
});
}

function deployFtp(config) {
return new Promise(function(resolve, reject) {
var ftp = new FtpDeploy();

ftp.on("uploading", function(data) {
console.log(
data.percentComplete + "% " +
"(" + data.transferredFileCount +
"/" + data.totalFileCount +
") " + data.filename
);
});

ftp.deploy(config, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

setupFiles()
.then(function(dir) {
var config = ftpConfig(dir, "/");
console.log("Deploying to ftp://" + config.host + ":" + config.port + "...");
return deployFtp(config);
})
.then(function() {
console.log("FTP deployment successful.");
if (chatBotRequest.apiKey) {
console.log("Posting message to " + chatBotConfig.url + "...");
return postToChat(chatBotConfig, chatBotRequest);
}
})
.then(function(responseBody) {
if (responseBody) {
console.log(responseBody);
}
})
.catch(function(err) {
console.error(err.toString());
console.error(err.stack);
});
4 changes: 3 additions & 1 deletion src/cardshifter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var topNavbar = require('./top_navbar/module');
var gameBoard = require("./game_board/module");
var test = require("./test/module");
var ngAnimate = require('angular-animate');
var errorCreator = require("./error/module");

angular.module("CardshifterApp", [
ngRoute,
Expand All @@ -20,7 +21,8 @@ angular.module("CardshifterApp", [
login.name,
gameBoard.name,
test.name,
uiBootstrap
uiBootstrap,
errorCreator.name
]).config(function($locationProvider) {
$locationProvider.html5Mode(true);
}).config(function($routeProvider) {
Expand Down
38 changes: 21 additions & 17 deletions src/deck_builder/controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// @ngInject
function DeckbuilderController(CardshifterServerAPI, $scope, $rootScope, $location) {
function DeckbuilderController(CardshifterServerAPI, $scope, $rootScope, $location, ErrorCreator) {
var DECK_STORAGE = "CARDSHIFTER_DECK_STORAGE";

$scope.cards = [];
Expand All @@ -28,25 +28,25 @@ function DeckbuilderController(CardshifterServerAPI, $scope, $rootScope, $locati
localStorage.setItem(DECK_STORAGE, json);
}

CardshifterServerAPI.setMessageListener(function(cardInformation) {
deckConfig = cardInformation
var deck = cardInformation.configs.Deck;
CardshifterServerAPI.setMessageListener({
"playerconfig": function(cardInformation) {
deckConfig = cardInformation
var deck = cardInformation.configs.Deck;

for(var card in deck.cardData) {
if(deck.cardData.hasOwnProperty(card)) {
deck.cardData[card].max = deck.max[card] || deck.maxPerCard;
$scope.currentDeck[deck.cardData[card].id] = 0;
for(var card in deck.cardData) {
if(deck.cardData.hasOwnProperty(card)) {
deck.cardData[card].max = deck.max[card] || deck.maxPerCard;
$scope.currentDeck[deck.cardData[card].id] = 0;
}
}
}

$scope.cards = deck.cardData;
$scope.maxCards = deck.maxSize;
$scope.minCards = deck.minSize;
updateSavedDecks();
$scope.doneLoading = true;

$scope.$apply();
}, ["playerconfig"]);
$scope.cards = deck.cardData;
$scope.maxCards = deck.maxSize;
$scope.minCards = deck.minSize;
updateSavedDecks();
$scope.doneLoading = true;
}
}, $scope);

/**
* This is called when the minus-sign button for a card
Expand Down Expand Up @@ -123,14 +123,17 @@ function DeckbuilderController(CardshifterServerAPI, $scope, $rootScope, $locati
*/
$scope.saveDeck = function() {
if($scope.getTotalSelected() !== $scope.minCards) {
ErrorCreator.create("Not enough cards");
console.log("not enough cards");
return;
}
if(!$scope.deckName) {
ErrorCreator.create("Please enter a name");
console.log("enter name");
return;
}
if(getDeckIndex($scope.deckName)) {
ErrorCreator.create("A deck with that name already exists");
console.log("deck already exists");
return;
}
Expand Down Expand Up @@ -213,6 +216,7 @@ function DeckbuilderController(CardshifterServerAPI, $scope, $rootScope, $locati

$location.path("/game_board");
} else {
ErrorCreator.create("Not enough cards");
console.log("not enough cards");
}
};
Expand Down
22 changes: 22 additions & 0 deletions src/error/error_creator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

function ErrorCreator($modal) {
return {
create: function(errorMessage) {
var errorModal = $modal.open({
animation: true,
backdrop: "static",
template: require("./error_popup.html"),
controller: "ErrorPopupController",
size: "sm",
resolve: {
message: function() {
return errorMessage;
}
}
});
}
}
}

module.exports = ErrorCreator;
11 changes: 11 additions & 0 deletions src/error/error_popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
<div class="modal-header">
<h3 class="modal-title">Error!</h3>
</div>
<div class="modal-body">
{{message}}!
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
</div>
</div>
12 changes: 12 additions & 0 deletions src/error/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";
var angular = require("angular");
var errorCreator = require("./error_creator");

module.exports = angular.module("cardshifter.errorCreator", [])
.service("ErrorCreator", errorCreator)
.controller("ErrorPopupController", function($scope, $modalInstance, message) {
$scope.message = message;
$scope.ok = function() {
$modalInstance.close();
};
});
Loading