Continued work on deck builder.

This commit is contained in:
marcins78@gmail.com
2011-09-04 15:10:14 +00:00
parent 0db0fb7498
commit 2cb4afa00a
6 changed files with 4600 additions and 62 deletions

View File

@@ -24,36 +24,10 @@
border: 2px solid #00cccc;
}
.player {
background-color: #000000;
color: #ffffff;
.ui-layout-east {
width: 350px;
}
.player.current {
background-color: #ffffff;
color: #000000;
}
.phase {
background-color: #000000;
color: #ffffff;
}
.phase.current {
background-color: #ffffff;
color: #000000;
}
.twilightPool {
float: right;
font-size: 30px;
width: 40px;
border-radius: 8px;
background-color: #000000;
color: #ffffff;
padding: 2px;
text-align: right;
}
</style>
<link rel="stylesheet" type="text/css" href="css/dark-hive/jquery-ui-1.8.16.custom.css">
<link rel="stylesheet" type="text/css" href="js/jquery/styles/jquery.spinnercontrol.css">
@@ -61,6 +35,8 @@
<script type="text/javascript" src="js/jquery/jquery-1.6.2.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery/jquery.layout.js"></script>
<script type="text/javascript" src="js/jquery/jquery.touchSwipe.js"></script>
<script type="text/javascript" src="js/inheritance.js"></script>
@@ -98,9 +74,17 @@
}
$(document).ready(
function () {
function() {
ui = new GempLotrDeckBuildingUI();
$('body').layout({
applyDefaultStyles: true,
onresize: function() {
ui.layoutUI();
},
east__minSize: "30%"
});
communication = new GempLotrCommunication("/gemp-lotr/server",
function() {
ui.processError();
@@ -126,7 +110,7 @@
</head>
<body>
<div id="main" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: #efefef;">
</div>
<div id="deckDiv" class="ui-layout-center"></div>
<div id="collectionDiv" class="ui-layout-east"></div>
</body>
</html>

View File

@@ -5,15 +5,14 @@ var GempLotrDeckBuildingUI = Class.extend({
loadCollectionFunc: null,
init: function() {
this.deckDiv = $("<div></div>");
this.collectionDiv = $("<div></div>");
this.deckDiv = $("#deckDiv");
this.collectionDiv = $("#collectionDiv");
this.collectionGroup = new NormalCardGroup(null, function(card) {
return (card.zone == "collection");
});
$("#main").append(this.deckDiv);
$("#main").append(this.collectionDiv);
},
setLoadCollectionFunc: function(func) {
@@ -43,14 +42,8 @@ var GempLotrDeckBuildingUI = Class.extend({
},
layoutUI: function() {
var width = $(window).width();
var height = $(window).height();
var deckHeight = Math.floor(height * 0.3);
this.deckDiv.css({left:0 + "px", top:0 + "px", width: width, height: deckHeight, position: "absolute"});
this.collectionDiv.css({left:0 + "px", top:deckHeight + "px", width: width, height: height - deckHeight, position: "absolute"});
this.collectionGroup.setBounds(0, 0, width, height - deckHeight);
this.collectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height());
},
processError: function (xhr, ajaxOptions, thrownError) {

View File

@@ -47,10 +47,10 @@ var GempLotrGameUI = Class.extend({
this.shadowAssignGroups = {};
this.freePeopleAssignGroups = {};
this.skirmishShadowGroup = new NormalCardGroup(null, function (card) {
this.skirmishShadowGroup = new NormalCardGroup(null, $("#main"), function (card) {
return card.zone == "SHADOW_CHARACTERS" && card.skirmish == true;
});
this.skirmishFellowshipGroup = new NormalCardGroup(null, function (card) {
this.skirmishFellowshipGroup = new NormalCardGroup(null, $("#main"), function (card) {
return (card.zone == "FREE_SUPPORT" || card.zone == "FREE_CHARACTERS") && card.skirmish == true;
});
@@ -64,32 +64,32 @@ var GempLotrGameUI = Class.extend({
var that = this;
this.supportOpponent = new NormalCardGroup("Free People Support of Opponent", function(card) {
this.supportOpponent = new NormalCardGroup("Free People Support of Opponent", $("#main"), function(card) {
return (card.zone == "FREE_SUPPORT" && card.owner != that.selfPlayerId && that.shadowAssignGroups[card.cardId] == null && card.skirmish == null);
});
this.charactersOpponent = new NormalCardGroup("Free People Characters of Opponent", function(card) {
this.charactersOpponent = new NormalCardGroup("Free People Characters of Opponent", $("#main"), function(card) {
return (card.zone == "FREE_CHARACTERS" && card.owner != that.selfPlayerId && that.shadowAssignGroups[card.cardId] == null && card.skirmish == null);
});
this.shadow = new NormalCardGroup("Shadow minions", function(card) {
this.shadow = new NormalCardGroup("Shadow minions", $("#main"), function(card) {
return (card.zone == "SHADOW_CHARACTERS" && card.assign == null && card.skirmish == null);
});
this.charactersPlayer = new NormalCardGroup("Free People Characters of Player", function(card) {
this.charactersPlayer = new NormalCardGroup("Free People Characters of Player", $("#main"), function(card) {
return (card.zone == "FREE_CHARACTERS" && card.owner == that.selfPlayerId && that.shadowAssignGroups[card.cardId] == null && card.skirmish == null);
});
this.supportPlayer = new NormalCardGroup("Free People Support of Player", function(card) {
this.supportPlayer = new NormalCardGroup("Free People Support of Player", $("#main"), function(card) {
return (card.zone == "FREE_SUPPORT" && card.owner == that.selfPlayerId && that.shadowAssignGroups[card.cardId] == null && card.skirmish == null);
});
this.hand = new NormalCardGroup("Hand", function(card) {
this.hand = new NormalCardGroup("Hand", $("#main"), function(card) {
return (card.zone == "HAND");
});
this.shadowOpponent = new NormalCardGroup("Shadow Support of Opponent", function(card) {
this.shadowOpponent = new NormalCardGroup("Shadow Support of Opponent", $("#main"), function(card) {
return (card.zone == "SHADOW_SUPPORT" && card.owner != that.selfPlayerId);
});
this.shadowPlayer = new NormalCardGroup("Shadow Support of Player", function(card) {
this.shadowPlayer = new NormalCardGroup("Shadow Support of Player", $("#main"), function(card) {
return (card.zone == "SHADOW_SUPPORT" && card.owner == that.selfPlayerId);
});
this.specialGroup = new NormalCardGroup(null, function(card) {
this.specialGroup = new NormalCardGroup(null, this.dialogInstance, function(card) {
return (card.zone == "SPECIAL");
});
this.specialGroup.setBounds(this.padding, this.padding, 400, 200);
@@ -910,11 +910,11 @@ var GempLotrGameUI = Class.extend({
}
if (this.shadowAssignGroups[characterId] == null) {
this.shadowAssignGroups[characterId] = new NormalCardGroup(null, function (card) {
this.shadowAssignGroups[characterId] = new NormalCardGroup(null, this.assignmentDialog, function (card) {
return (card.zone == "SHADOW_CHARACTERS" && card.assign == characterId);
}
);
this.freePeopleAssignGroups[characterId] = new NormalCardGroup(null, function (card) {
this.freePeopleAssignGroups[characterId] = new NormalCardGroup(null, this.assignmentDialog, function (card) {
return (card.cardId == characterId);
}
);

View File

@@ -1,4 +1,5 @@
var CardGroup = Class.extend({
container: null,
x: null,
y: null,
width: null,
@@ -7,7 +8,8 @@ var CardGroup = Class.extend({
padding: 5,
cardId: null,
init: function(belongTest) {
init: function(container, belongTest) {
this.container = container;
this.belongTestFunc = belongTest;
},
@@ -58,8 +60,8 @@ var CardGroup = Class.extend({
});
var AdvPathCardGroup = CardGroup.extend({
init: function() {
this._super(
init: function(container) {
this._super(container,
function(card) {
return (card.zone == "ADVENTURE_PATH");
});
@@ -68,7 +70,7 @@ var AdvPathCardGroup = CardGroup.extend({
layoutCards: function() {
var cardsToLayout = new Array();
var that = this;
$(".card").each(function(index) {
$(".card", this.container).each(function(index) {
var card = $(this).data("card");
if (that.belongTestFunc(card)) {
cardsToLayout.push($(this));
@@ -106,8 +108,8 @@ var AdvPathCardGroup = CardGroup.extend({
var NormalCardGroup = CardGroup.extend({
descDiv: null,
init: function(text, belongTest) {
this._super(belongTest);
init: function(text, container, belongTest) {
this._super(container, belongTest);
if (text != null) {
this.descDiv = $("<div>" + text + "</div>");
$("#main").append(this.descDiv);
@@ -123,7 +125,7 @@ var NormalCardGroup = CardGroup.extend({
layoutCards: function() {
var cardsToLayout = new Array();
var that = this;
$(".card").each(function(index) {
$(".card", this.container).each(function(index) {
var card = $(this).data("card");
if (that.belongTestFunc(card)) {
cardsToLayout.push($(this));

View File

@@ -0,0 +1,92 @@
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

File diff suppressed because it is too large Load Diff