Commit b4735776 authored by haiyoucuv's avatar haiyoucuv

1

parent 2c8b7486
This diff is collapsed.
function ListNode(value, next, last) {
this.value = value;
this.next = next;
this.last = last;
}
ListNode.prototype.value = null;
ListNode.prototype.next = null;
ListNode.prototype.last = null;
function List() {
}
List.prototype.head = null;
List.prototype.tail = null;
List.prototype.length = null;
List.prototype.getNodeByIndex = function (index = 0) {
if (index < -this.length || index >= this.length) {
console.error('out of range');
return null;
}
if (index === 0 || index === -this.length) {
return this.head;
} else if (index === this.length - 1 || index === -1) {
return this.tail;
} else if (index > 0) {
let last = this.head;
for (let i = 1; i <= index; i++) {
last = last.next;
}
return last;
} else if (index < 0) {
let next = this.tail;
for (let i = -2; i >= index; i--) {
next = next.last;
}
return next;
}
}
List.prototype.increase = function (value, index = this.length - 1) {
const opNode = this.getNodeByIndex(index);
if (!opNode) {
return;
}
opNode.value += value;
if (opNode.value >= 10) {
const out = ~~(opNode.value / 10);
opNode.value = opNode.value % 10;
this.increase(out, index - 1);
}
}
List.createList = function (...value) {
const newList = new List();
let last = new ListNode(value[0], null, null);
newList.head = last;
for (let i = 1; i < value.length; i++) {
let newNode = new ListNode(value[i], null, last);
last.next = newNode;
last = newNode;
}
newList.tail = last;
newList.length = value.length;
return newList;
}
const list = List.createList(1, 2, 3, 4);
list.increase(10, 2);
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
"data": { "data": {
"tools": { "tools": {
"HAMMERS": 1, "HAMMERS": 1,
"STEPS": 0, "STEPS": 1,
"BOOMS": 0 "BOOMS": 1
} }
}, },
"success": true, "success": true,
......
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
"power": 3, "power": 3,
"tools": { "tools": {
"HAMMERS": 1, "HAMMERS": 1,
"STEPS": 0, "STEPS": 1,
"BOOMS": 0 "BOOMS": 1
}, },
"topAward": "" "topAward": ""
}, },
......
...@@ -79,9 +79,9 @@ export class SuccessNoPrizePanel extends Panel { ...@@ -79,9 +79,9 @@ export class SuccessNoPrizePanel extends Panel {
if (curLevel <= value && d >= 0 && d <= dLevel) { if (curLevel <= value && d >= 0 && d <= dLevel) {
upLevel = value; upLevel = value;
if (curLevel == this.data.level) { if (curLevel == this.data.level) {
dLevel = d + 1;
} else {
dLevel = d; dLevel = d;
} else {
dLevel = d + 1;
} }
} }
}); });
......
...@@ -62,7 +62,8 @@ export class MapScene extends Scene { ...@@ -62,7 +62,8 @@ export class MapScene extends Scene {
let openPrize = GTool.readCache('openPrize'); let openPrize = GTool.readCache('openPrize');
if (Tools.gameData.topAward && Tools.gameData.topAward._id && openPrize !== 'true') { if (Tools.gameData.topAward && Tools.gameData.topAward._id && openPrize !== 'true') {
GTool.writeCache('openPrize', 'true'); GTool.writeCache('openPrize', 'true');
showPanel(PrizePanel, Tools.gameData.topAward); showPanel(PrizePanel, JSON.parse(JSON.stringify(Tools.gameData.topAward)));
Tools.gameData.topAward = null;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment