Skip to content

Commit fa3e8e9

Browse files
committed
Update equip AI.
Use get.position instead of getEquips for value and equipValue functions.
1 parent edf881b commit fa3e8e9

File tree

2 files changed

+13
-72
lines changed

2 files changed

+13
-72
lines changed

card/yongjian.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,11 @@ game.import("card", function () {
212212
ai: {
213213
order: 9,
214214
value: function (card, player) {
215-
let e_cards = player.getCards("e");
216-
for (let i of e_cards) {
217-
if (get.subtype(i) == "equip1" && i == card) return 0.4;
218-
}
219-
if (player.getEquips(1).includes(card)) return 0.4;
215+
if (get.position(card) == "e") return 0.4;
220216
return 4;
221217
},
222218
equipValue: function (card, player) {
223-
let e_cards = player.getCards("e");
224-
for (let i of e_cards) {
225-
if (get.subtype(i) == "equip1" && i == card) return 0.4;
226-
}
227-
if (player.getEquips(1).includes(card)) return 0.4;
219+
if (get.position(card) == "e") return 0.4;
228220
return -get.value(player.getCards("e"));
229221
},
230222
basic: {
@@ -265,11 +257,7 @@ game.import("card", function () {
265257
return 2;
266258
},
267259
value: function (card, player) {
268-
let e_cards = player.getCards("e");
269-
for (let i of e_cards) {
270-
if (get.subtype(i) == "equip1" && i == card) return -3;
271-
}
272-
if (player.getEquips(1).includes(card)) return -3;
260+
if (get.position(card) == "e") return -3;
273261
return 3;
274262
},
275263
basic: {
@@ -305,14 +293,7 @@ game.import("card", function () {
305293
return 2;
306294
},
307295
value: function (card, player) {
308-
let e_cards = player.getCards("e");
309-
for (let i of e_cards) {
310-
if (get.subtype(i) == "equip2" && i == card) {
311-
if (player.hasSex("male")) return -8;
312-
return 0;
313-
}
314-
}
315-
if (player.getEquips(2).includes(card)) {
296+
if (get.position(card) == "e") {
316297
if (player.hasSex("male")) return -8;
317298
return 0;
318299
}
@@ -349,11 +330,7 @@ game.import("card", function () {
349330
return 1;
350331
},
351332
value: function (card, player) {
352-
let e_cards = player.getCards("e");
353-
for (let i of e_cards) {
354-
if (get.subtype(i) == "equip2" && i == card) return -10;
355-
}
356-
if (player.getEquips(2).includes(card)) return -10;
333+
if (get.position(card) == "e") return -10;
357334
return 2.5;
358335
},
359336
basic: {
@@ -386,11 +363,7 @@ game.import("card", function () {
386363
order: 9,
387364
equipValue: -1,
388365
value: function (card, player) {
389-
let e_cards = player.getCards("e");
390-
for (let i of e_cards) {
391-
if (get.subtype(i) == "equip4" && i == card) return 0;
392-
}
393-
if (player.getEquips(4).includes(card)) return 0;
366+
if (get.position(card) == "e") return 0;
394367
return 0.5;
395368
},
396369
basic: {

card/zhulu.js

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,11 @@ game.import("card", function () {
380380
ai: {
381381
order: 9,
382382
value: function (card, player) {
383-
let e_cards = player.getCards("e");
384-
for (let i of e_cards) {
385-
if (get.subtype(i) == "equip4" && i == card) return 0;
386-
}
387-
if (player.getEquips(4).includes(card)) return 0;
383+
if (get.position(card) == "e") return 0;
388384
return 4;
389385
},
390386
equipValue: function (card, player) {
391-
let e_cards = player.getCards("e");
392-
for (let i of e_cards) {
393-
if (get.subtype(i) == "equip4" && i == card) return 0;
394-
}
395-
if (player.getEquips(4).includes(card)) return 0;
387+
if (get.position(card) == "e") return 0;
396388
return -get.value(player.getCards("e"));
397389
},
398390
basic: {
@@ -467,14 +459,7 @@ game.import("card", function () {
467459
return 2;
468460
},
469461
value: function (card, player) {
470-
let e_cards = player.getCards("e");
471-
for (let i of e_cards) {
472-
if (get.subtype(i) == "equip1" && i == card) {
473-
if (player.hasSkillTag("noh")) return 0;
474-
return -3.5;
475-
}
476-
}
477-
if (player.getEquips(1).includes(card)) {
462+
if (get.position(card) == "e") {
478463
if (player.hasSkillTag("noh")) return 0;
479464
return -3.5;
480465
}
@@ -515,11 +500,7 @@ game.import("card", function () {
515500
return 2;
516501
},
517502
value: function (card, player) {
518-
let e_cards = player.getCards("e");
519-
for (let i of e_cards) {
520-
if (get.subtype(i) == "equip1" && i == card) return -3.5;
521-
}
522-
if (player.getEquips(1).includes(card)) return -3.5;
503+
if (get.position(card) == "e") return -3.5;
523504
return 3;
524505
},
525506
basic: {
@@ -557,11 +538,7 @@ game.import("card", function () {
557538
return 1;
558539
},
559540
value: function (card, player) {
560-
let e_cards = player.getCards("e");
561-
for (let i of e_cards) {
562-
if (get.subtype(i) == "equip2" && i == card) return -9;
563-
}
564-
if (player.getEquips(2).includes(card)) return -9;
541+
if (get.position(card) == "e") return -9;
565542
return 2.5;
566543
},
567544
basic: {
@@ -627,11 +604,7 @@ game.import("card", function () {
627604
ai:{
628605
order: 9.5,
629606
equipValue: function (card, player) {
630-
let e_cards = player.getCards("e");
631-
for (let i of e_cards) {
632-
if (get.subtype(i) == "equip2" && i == card) return 0;
633-
}
634-
if (player.getEquips(2).includes(card)) return 0;
607+
if (get.position(card) == "e") return 0;
635608
return 1;
636609
},
637610
value: function () {
@@ -744,19 +717,14 @@ game.import("card", function () {
744717
ai: {
745718
order: 9.5,
746719
equipValue: function (card, player) {
747-
if (!player.getVEquips(5).includes(card)) return 5;
748-
if (_status.jinhe&&_status.jinhe[card.cardid]&&(_status.event.name=='discardPlayerCard'||_status.event.name=='chooseToDiscard'||_status.event.name=='chooseToUse')) return 1+3*player.countCards('h');
720+
if ((get.position(card?.cards?.[0]) == "e") && card?.cards?.[0]?.cardid) return 1+3*player.countCards('h');
749721
return 0;
750722
},
751723
value: function () {
752724
return lib.card.jinhe.ai.equipValue.apply(this, arguments);
753725
},
754726
basic: {
755727
equipValue: 5,
756-
value: function(card,player,i) {
757-
if (_status.jinhe&&_status.jinhe[card.cardid]&&(_status.event.name=='discardPlayerCard'||_status.event.name=='chooseToDiscard'||_status.event.name=='chooseToUse')) return 1+2*player.countCards('h');
758-
return 0;
759-
},
760728
},
761729
result: {
762730
keepAI: true,

0 commit comments

Comments
 (0)