Working on merchant, finished.

This commit is contained in:
marcins78@gmail.com
2012-03-14 02:17:31 +00:00
parent 0fe63d7fb5
commit 85aa38fe7d
10 changed files with 77 additions and 11 deletions

View File

@@ -0,0 +1,13 @@
package com.gempukku.lotro;
import com.gempukku.lotro.game.Player;
public class PlayerLock {
public static Object getLock(Player player) {
return player.getName().intern();
}
public static Object getLock(String playerName) {
return playerName.intern();
}
}

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.server;
import com.gempukku.lotro.DateUtils;
import com.gempukku.lotro.PlayerLock;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.collection.DeliveryService;
import com.gempukku.lotro.db.PlayerDAO;
@@ -28,18 +29,19 @@ public abstract class AbstractResource {
String logged = getLoggedUser(request);
if (logged != null) {
Player player = _playerDao.getPlayer(logged);
synchronized (PlayerLock.getLock(player)) {
int currentDate = DateUtils.getCurrentDate();
int latestMonday = DateUtils.getMondayBeforeOrOn(currentDate);
int currentDate = DateUtils.getCurrentDate();
int latestMonday = DateUtils.getMondayBeforeOrOn(currentDate);
Integer lastReward = player.getLastLoginReward();
if (lastReward == null) {
_playerDao.setLastReward(player, latestMonday);
_collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 20000);
} else {
if (latestMonday == lastReward) {
if (_playerDao.updateLastReward(player, lastReward, latestMonday))
_collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 5000);
Integer lastReward = player.getLastLoginReward();
if (lastReward == null) {
_playerDao.setLastReward(player, latestMonday);
_collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 20000);
} else {
if (latestMonday != lastReward) {
if (_playerDao.updateLastReward(player, lastReward, latestMonday))
_collectionManager.addCurrencyToPlayerCollection(player, new CollectionType("permanent", "My cards"), 5000);
}
}
}
}

View File

@@ -20,6 +20,16 @@
opacity: 0.2;
}
.pocket {
background-color: #000000;
border: 1px solid #ffffff;
color: #ffffff;
font-size: 90%;
font-weight: bolder;
text-align: right;
opacity: 1;
}
.cardCount {
width: 20px;
height: 18px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View File

@@ -11,6 +11,8 @@ var GempLotrHallUI = Class.extend({
tablesDiv: null,
buttonsDiv: null,
pocketDiv: null,
init: function(div, url, chat) {
this.div = div;
this.comm = new GempLotrCommunication(url, function(xhr, ajaxOptions, thrownError) {
@@ -49,9 +51,22 @@ var GempLotrHallUI = Class.extend({
location.href = 'deckBuild.html';
});
var merchant = $("<button>Merchant</button>");
merchant.button().click(
function() {
location.href = 'merchant.html';
});
this.buttonsDiv.append(editDeck);
this.buttonsDiv.append(" | ");
this.buttonsDiv.append(merchant);
this.buttonsDiv.append(" | ");
this.pocketDiv = $("<div class='pocket'></div>");
this.pocketDiv.css({"float": "right", width: 75, height: 18});
this.buttonsDiv.append(this.pocketDiv);
this.supportedFormatsSelect = $("<select style='width: 220px'></select>");
this.supportedFormatsSelect.hide();
@@ -140,11 +155,18 @@ var GempLotrHallUI = Class.extend({
}
},
formatPrice: function(price) {
return Math.floor(price / 100) + "G " + price % 100 + "S";
},
processHall: function(xml) {
var root = xml.documentElement;
if (root.tagName == "hall") {
this.tablesDiv.html("");
var currency = root.getAttribute("currency");
this.pocketDiv.html(this.formatPrice(currency));
var motd = root.getAttribute("motd");
if (motd != null)
$("#motd").html(motd);

View File

@@ -7,6 +7,8 @@ var GempLotrMerchantUI = Class.extend({
filterDiv: null,
cardFilter: null,
pocketDiv: null,
infoDialog: null,
questionDialog: null,
@@ -38,6 +40,10 @@ var GempLotrMerchantUI = Class.extend({
this.filterDiv = cardFilterElem;
this.pocketDiv = $("<div class='pocket'></div>");
this.filterDiv.append(this.pocketDiv);
this.infoDialog = $("<div></div>")
.dialog({
autoOpen: false,
@@ -172,6 +178,7 @@ var GempLotrMerchantUI = Class.extend({
clearList: function(rootElem) {
$(".card", this.cardsDiv).remove();
this.currencyCount = rootElem.getAttribute("currency");
this.pocketDiv.html(this.formatPrice(this.currencyCount));
},
addCardToList: function(elem, type, blueprintId, count) {
@@ -305,6 +312,8 @@ var GempLotrMerchantUI = Class.extend({
var filterWidth = $(this.filterDiv).width();
var filterHeight = $(this.filterDiv).height();
this.cardFilter.layoutUi(0, 0, filterWidth, filterHeight);
this.pocketDiv.css({position: "absolute", left: filterWidth - 60, top: 35, width: 60, height: 18});
},
processError: function (xhr, ajaxOptions, thrownError) {

View File

@@ -31,6 +31,16 @@
opacity: 0.7;
}
.pocket {
background-color: #000000;
border: 1px solid #ffffff;
color: #ffffff;
font-size: 100%;
font-weight: bolder;
text-align: right;
opacity: 1;
}
.buyPrice, .sellPrice, .tradeFoil {
opacity: 0.9;
}