mirror of
https://github.com/webxoss/webxoss-core.git
synced 2025-01-31 01:39:09 +01:00
review
This commit is contained in:
parent
012308b4a4
commit
3b85cef504
2 changed files with 35 additions and 21 deletions
|
@ -214,7 +214,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span> p2 </span>
|
<span> p2 </span>
|
||||||
<select id="ghost-decks"></select>
|
<select id="guest-decks"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -231,7 +231,7 @@
|
||||||
<div>
|
<div>
|
||||||
<span>to</span>
|
<span>to</span>
|
||||||
<select id="target-player" class="target-player">
|
<select id="target-player" class="target-player">
|
||||||
<option value="">yourself's</option>
|
<option value="">turn player's</option>
|
||||||
<option value="opponent">opponent's</option>
|
<option value="opponent">opponent's</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -246,7 +246,7 @@
|
||||||
<button onclick="resetLrigDeck();">reset lrig deck</button>
|
<button onclick="resetLrigDeck();">reset lrig deck</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-center">
|
<div class="flex-center">
|
||||||
<textarea id="log"></textarea>
|
<textarea id="log" readonly="readonly"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="language">
|
<div class="language">
|
||||||
<span>Language:</span>
|
<span>Language:</span>
|
||||||
|
@ -261,7 +261,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<iframe id="deck-editor" src="../webxoss-client/DeckEditor/" scrolling="no" frameborder="no" border="0"></iframe>
|
<iframe id="deck-editor" src="./webxoss-client/DeckEditor/" scrolling="no" frameborder="no" border="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
@ -329,7 +329,6 @@ button {
|
||||||
button:disabled,
|
button:disabled,
|
||||||
button[disabled] {
|
button[disabled] {
|
||||||
border: none;
|
border: none;
|
||||||
filter: alpha(opacity=40);
|
|
||||||
opacity: .4;
|
opacity: .4;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ function disableAudio(doc) {
|
||||||
sound.click();
|
sound.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initClient(win) {
|
function initClient(win) {
|
||||||
var doc = win.document;
|
var doc = win.document;
|
||||||
var socket = new FakeSocket(win);
|
var socket = new FakeSocket(win);
|
||||||
|
@ -42,11 +43,12 @@ function startBattle() {
|
||||||
location.reload();
|
location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var win = window.open('../webxoss-client/?local=true');
|
var win = window.open('./webxoss-client/?local=true');
|
||||||
win.addEventListener('load', function() {
|
win.addEventListener('load', function() {
|
||||||
var win2 = window.open('../webxoss-client/?local=true');
|
var win2 = window.open('./?local=true');
|
||||||
win2.addEventListener('load', function() {
|
win2.addEventListener('load', function() {
|
||||||
initClient(win2);
|
initClient(win2);
|
||||||
|
skipDiscards();
|
||||||
oben();
|
oben();
|
||||||
});
|
});
|
||||||
initClient(win);
|
initClient(win);
|
||||||
|
@ -69,7 +71,7 @@ function oben() {
|
||||||
|
|
||||||
var joinRoomMsg = {
|
var joinRoomMsg = {
|
||||||
'roomName': 'test',
|
'roomName': 'test',
|
||||||
'nickname': 'ghost',
|
'nickname': 'guest',
|
||||||
'password': '',
|
'password': '',
|
||||||
};
|
};
|
||||||
sockets[1]._doEmit('joinRoom', joinRoomMsg);
|
sockets[1]._doEmit('joinRoom', joinRoomMsg);
|
||||||
|
@ -77,7 +79,7 @@ function oben() {
|
||||||
|
|
||||||
sockets[1]._doEmit('ready', getDeckPids('host'));
|
sockets[1]._doEmit('ready', getDeckPids('host'));
|
||||||
log('Client<2> is ready.');
|
log('Client<2> is ready.');
|
||||||
sockets[0]._doEmit('startGame', getDeckPids('ghost'));
|
sockets[0]._doEmit('startGame', getDeckPids('guest'));
|
||||||
log('oben!');
|
log('oben!');
|
||||||
|
|
||||||
handleBattle();
|
handleBattle();
|
||||||
|
@ -95,6 +97,11 @@ function handleBattle() {
|
||||||
log('Now you can use helper function.');
|
log('Now you can use helper function.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function skipDiscards() {
|
||||||
|
Player.prototype.redrawAsyn = function() {
|
||||||
|
return new Callback.immediately();
|
||||||
|
}
|
||||||
|
}
|
||||||
// helper function
|
// helper function
|
||||||
function grow() {
|
function grow() {
|
||||||
var p = game.turnPlayer;
|
var p = game.turnPlayer;
|
||||||
|
@ -112,11 +119,10 @@ function grow() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lrigCards.pop().moveTo(p.lrigZone);
|
lrigCards.pop().moveTo(p.lrigZone);
|
||||||
lrigCards.forEach(function(card) {
|
game.moveCards(lrigCards, p.lrigZone, { bottom: true });
|
||||||
card.moveTo(p.lrigZone, {bottom: true});
|
|
||||||
});
|
|
||||||
log('grow lrig to max level.');
|
log('grow lrig to max level.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(num) {
|
function draw(num) {
|
||||||
if (!num) {
|
if (!num) {
|
||||||
num = 5;
|
num = 5;
|
||||||
|
@ -125,6 +131,7 @@ function draw(num) {
|
||||||
p.draw(num);
|
p.draw(num);
|
||||||
log('draw ' + num + ' cards.');
|
log('draw ' + num + ' cards.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function charge(num) {
|
function charge(num) {
|
||||||
if (!num) {
|
if (!num) {
|
||||||
num = 5;
|
num = 5;
|
||||||
|
@ -145,9 +152,9 @@ function matchCard(arg) {
|
||||||
var card = game.cards[i];
|
var card = game.cards[i];
|
||||||
var info = CardInfo[card.cid];
|
var info = CardInfo[card.cid];
|
||||||
var matched = info.name === arg ||
|
var matched = info.name === arg ||
|
||||||
info.name_zh_CN === arg ||
|
info.name_zh_CN === arg ||
|
||||||
info.cid === arg ||
|
info.cid === arg ||
|
||||||
info.wxid === arg;
|
info.wxid === arg;
|
||||||
if (matched) {
|
if (matched) {
|
||||||
cid = card.cid;
|
cid = card.cid;
|
||||||
break;
|
break;
|
||||||
|
@ -155,7 +162,7 @@ function matchCard(arg) {
|
||||||
}
|
}
|
||||||
if (!cid) return null;
|
if (!cid) return null;
|
||||||
var p = selectPlayer();
|
var p = selectPlayer();
|
||||||
var cards = concat(p.mainDeck.cards,p.trashZone.cards,p.enerZone.cards,p.lifeClothZone.cards);
|
var cards = concat(p.mainDeck.cards, p.trashZone.cards, p.enerZone.cards, p.lifeClothZone.cards);
|
||||||
for (var j = 0; j < cards.length; j++) {
|
for (var j = 0; j < cards.length; j++) {
|
||||||
var card = cards[j];
|
var card = cards[j];
|
||||||
if (card.cid === cid) {
|
if (card.cid === cid) {
|
||||||
|
@ -171,6 +178,7 @@ var zones = [
|
||||||
'trashZone',
|
'trashZone',
|
||||||
'lifeClothZone',
|
'lifeClothZone',
|
||||||
];
|
];
|
||||||
|
|
||||||
function addTo(zone) {
|
function addTo(zone) {
|
||||||
if (zones.indexOf(zone) === -1) {
|
if (zones.indexOf(zone) === -1) {
|
||||||
log('no such zone: ' + zone);
|
log('no such zone: ' + zone);
|
||||||
|
@ -208,10 +216,11 @@ function selectPlayer() {
|
||||||
game.turnPlayer.opponent :
|
game.turnPlayer.opponent :
|
||||||
game.turnPlayer;
|
game.turnPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeckPids(player) {
|
function getDeckPids(player) {
|
||||||
var name = {
|
var name = {
|
||||||
'host': $('host-decks').value || '',
|
'host': $('host-decks').value || '',
|
||||||
'ghost': $('host-decks').value || '',
|
'guest': $('host-decks').value || '',
|
||||||
}[player];
|
}[player];
|
||||||
if (!name) {
|
if (!name) {
|
||||||
log('error in deck select');
|
log('error in deck select');
|
||||||
|
@ -219,34 +228,39 @@ function getDeckPids(player) {
|
||||||
return JSON.parse(localStorage.getItem('deck_file_' + name));
|
return JSON.parse(localStorage.getItem('deck_file_' + name));
|
||||||
}
|
}
|
||||||
var deckNames = [];
|
var deckNames = [];
|
||||||
|
|
||||||
function readDeckNames() {
|
function readDeckNames() {
|
||||||
return JSON.parse(localStorage.getItem('deck_filenames')) || [];
|
return JSON.parse(localStorage.getItem('deck_filenames')) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDeckSelect() {
|
function initDeckSelect() {
|
||||||
deckNames = readDeckNames();
|
deckNames = readDeckNames();
|
||||||
var hostDeckSelect = $('host-decks');
|
var hostDeckSelect = $('host-decks');
|
||||||
var ghostDeckSelect = $('ghost-decks');
|
var guestDeckSelect = $('guest-decks');
|
||||||
hostDeckSelect.innerHTML = '';
|
hostDeckSelect.innerHTML = '';
|
||||||
ghostDeckSelect.innerHTML = '';
|
guestDeckSelect.innerHTML = '';
|
||||||
deckNames.forEach(function(name) {
|
deckNames.forEach(function(name) {
|
||||||
var deckName = document.createElement('option');
|
var deckName = document.createElement('option');
|
||||||
deckName.setAttribute('value', name);
|
deckName.setAttribute('value', name);
|
||||||
deckName.textContent = name;
|
deckName.textContent = name;
|
||||||
hostDeckSelect.appendChild(deckName);
|
hostDeckSelect.appendChild(deckName);
|
||||||
ghostDeckSelect.appendChild(deckName.cloneNode(true));
|
guestDeckSelect.appendChild(deckName.cloneNode(true));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeLanguage() {
|
function changeLanguage() {
|
||||||
var lang = $('select-language').value;
|
var lang = $('select-language').value;
|
||||||
localStorage.setItem('language', lang);
|
localStorage.setItem('language', lang);
|
||||||
log('set language to ' + lang + '.');
|
log('set language to ' + lang + '.');
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resizeIFrameToFitContent() {
|
function resizeIFrameToFitContent() {
|
||||||
var iFrame = $('deck-editor');
|
var iFrame = $('deck-editor');
|
||||||
iFrame.width = iFrame.contentWindow.document.body.scrollWidth;
|
iFrame.width = iFrame.contentWindow.document.body.scrollWidth;
|
||||||
iFrame.height = iFrame.contentWindow.document.body.scrollHeight;
|
iFrame.height = iFrame.contentWindow.document.body.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableButtons() {
|
function enableButtons() {
|
||||||
var buttons = document.getElementsByTagName('button');
|
var buttons = document.getElementsByTagName('button');
|
||||||
for (var i = 0; i < buttons.length; i++) {
|
for (var i = 0; i < buttons.length; i++) {
|
||||||
|
@ -255,6 +269,7 @@ function enableButtons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableButtons() {
|
function disableButtons() {
|
||||||
var buttons = document.getElementsByTagName('button');
|
var buttons = document.getElementsByTagName('button');
|
||||||
for (var i = 0; i < buttons.length; i++) {
|
for (var i = 0; i < buttons.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue