forked from Mogara/QSanguosha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanguosha.i
1614 lines (1332 loc) · 61.5 KB
/
sanguosha.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************************************************************
Copyright (c) 2013-2014 - QSanguosha-Rara
This file is part of QSanguosha-Hegemony.
This game is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3.0
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
See the LICENSE file for more details.
QSanguosha-Rara
*********************************************************************/
%module sgs
%{
#include "structs.h"
#include "engine.h"
#include "client.h"
#include "namespace.h"
#include "standard.h"
#include "roomthread.h"
#include <QDir>
%}
%include "naturalvar.i"
%include "native.i"
%include "qvariant.i"
%include "list.i"
%include "set.i"
// ----------------------------------------
namespace HegemonyMode {
QString GetMappedRole(const char *kingdom);
QString GetMappedKingdom(const char *role);
enum ArrayType {
Siege,
Formation
};
};
namespace MaxCardsType {
enum MaxCardsCount {
Max = 1,
Normal = 0,
Min = -1,
};
};
class QObject {
public:
QString objectName();
void setObjectName(const char *name);
bool inherits(const char *class_name);
bool setProperty(const char *name, const QVariant &value);
QVariant property(const char *name) const;
void setParent(QObject *parent);
void deleteLater();
};
class General: public QObject {
public:
explicit General(Package *package, const char *name, const char *kingdom, int double_max_hp = 4, bool male = true, bool hidden = false, bool never_shown = false);
// property getters/setters
int getDoubleMaxHp() const;
QString getKingdom() const;
bool isMale() const;
bool isFemale() const;
bool isNeuter() const;
bool isLord() const;
bool isHidden() const;
bool isTotallyHidden() const;
int getMaxHpHead() const;
int getMaxHpDeputy() const;
enum Gender { Sexless, Male, Female, Neuter };
Gender getGender() const;
void setGender(Gender gender);
void addSkill(Skill *skill);
void addSkill(const char *skill_name);
bool hasSkill(const char *skill_name) const;
QList<const Skill *> getSkillList(bool relate_to_place = false, bool head_only = true) const;
QList<const Skill *> getVisibleSkillList(bool relate_to_place = false, bool head_only = true) const;
void addRelateSkill(const char *skill_name);
QStringList getRelatedSkillNames() const;
QString getPackage() const;
QString getCompanions() const;
QString getSkillDescription(bool include_name = false, bool inToolTip = true) const;
void addCompanion(const char *name);
bool isCompanionWith(const char *name) const;
void setHeadMaxHpAdjustedValue(int adjusted_value = -1);
void setDeputyMaxHpAdjustedValue(int adjusted_value = -1);
void lastWord(const int skinId) const;
};
class Player: public QObject {
public:
enum Phase { RoundStart, Start, Judge, Draw, Play, Discard, Finish, NotActive, PhaseNone };
enum Place { PlaceHand, PlaceEquip, PlaceDelayedTrick, PlaceJudge, PlaceSpecial, DiscardPile, DrawPile, PlaceTable, PlaceUnknown, PlaceWuGu, DrawPileBottom };
enum Role { Lord, Loyalist, Rebel, Renegade };
explicit Player(QObject *parent);
void setScreenName(const char *screen_name);
QString screenName() const;
// property setters/getters
int getHp() const;
void setHp(int hp);
int getMaxHp() const;
void setMaxHp(int max_hp);
int getLostHp() const;
bool isWounded() const;
General::Gender getGender() const;
virtual void setGender(General::Gender gender);
bool isMale() const;
bool isFemale() const;
bool isNeuter() const;
bool isOwner() const;
void setOwner(bool owner);
bool hasShownRole() const;
void setShownRole(bool shown);
void setDisableShow(const char *flags, const char *reason);
void removeDisableShow(const char *reason);
QStringList disableShow(bool head) const;
QString getKingdom() const;
void setKingdom(const char *kingdom);
void setRole(const char *role);
QString getRole() const;
Role getRoleEnum() const;
void setGeneral(const General *general);
void setGeneralName(const char *general_name);
QString getGeneralName() const;
void setGeneral2Name(const char *general_name);
QString getGeneral2Name() const;
const General *getGeneral2() const;
QString getFootnoteName() const;
void setState(const char *state);
QString getState() const;
int getSeat() const;
void setSeat(int seat);
bool isAdjacentTo(const Player *another) const;
QString getPhaseString() const;
void setPhaseString(const char *phase_str);
Phase getPhase() const;
void setPhase(Phase phase);
int getAttackRange(bool include_weapon = true) const;
bool inMyAttackRange(const Player *other) const;
bool isAlive() const;
bool isDead() const;
void setAlive(bool alive);
QString getFlags() const;
QStringList getFlagList() const;
virtual void setFlags(const char *flag);
bool hasFlag(const char *flag) const;
void clearFlags();
bool faceUp() const;
void setFaceUp(bool face_up);
virtual int aliveCount(bool includeRemoved = true) const = 0;
void setFixedDistance(const Player *player, int distance);
int originalRightDistanceTo(const Player *other) const;
int distanceTo(const Player *other, int distance_fix = 0) const;
const General *getAvatarGeneral() const;
const General *getGeneral() const;
bool isLord() const;
void acquireSkill(const char *skill_name, bool head = true);
void detachSkill(const char *skill_name);
void detachAllSkills();
virtual void addSkill(const char *skill_name, bool head_skill = true);
virtual void loseSkill(const char *skill_name);
bool hasSkill(const char *skill_name, bool include_lose = false) const;
bool hasSkill(const Skill *skill, bool include_lose = false) const;
bool hasSkills(const char *skill_name, bool include_lose = false) const;
bool hasInnateSkill(const char *skill_name) const;
bool hasLordSkill(const char *skill_name, bool include_lose = false) const;
virtual QString getGameMode() const = 0;
void setEquip(WrappedCard *equip);
void removeEquip(WrappedCard *equip);
bool hasEquip(const Card *card) const;
bool hasEquip() const;
QList<const Card *> getJudgingArea() const;
QList<int> getJudgingAreaID() const; //for marshal
void addDelayedTrick(const Card *trick);
void removeDelayedTrick(const Card *trick);
bool containsTrick(const char *trick_name) const;
virtual int getHandcardNum() const = 0;
virtual void removeCard(const Card *card, Place place) = 0;
virtual void addCard(const Card *card, Place place) = 0;
virtual QList<const Card *> getHandcards() const = 0;
WrappedCard *getWeapon() const;
WrappedCard *getArmor() const;
WrappedCard *getDefensiveHorse() const;
WrappedCard *getOffensiveHorse() const;
WrappedCard *getTreasure() const;
QList<const Card *> getEquips() const;
const EquipCard *getEquip(int index) const;
bool hasWeapon(const char *weapon_name) const;
bool hasArmorEffect(const char *armor_name) const;
bool hasTreasure(const char *treasure_name) const;
bool isKongcheng() const;
bool isNude() const;
bool isAllNude() const;
bool canDiscard(const Player *to, const char *flags) const;
bool canDiscard(const Player *to, int card_id) const;
void addMark(const char *mark, int add_num = 1);
void removeMark(const char *mark, int remove_num = 1);
virtual void setMark(const char *mark, int value);
int getMark(const char *mark) const;
void setChained(bool chained);
bool isChained() const;
bool canBeChainedBy(const Player *source = NULL) const;
void setRemoved(bool removed);
bool isRemoved() const;
bool isDuanchang(const bool head = true) const;
bool canSlash(const Player *other, const Card *slash, bool distance_limit = true, int rangefix = 0, const QList<const Player *> &others = QList<const Player *>()) const;
bool canSlash(const Player *other, bool distance_limit = true, int rangefix = 0, const QList<const Player *> &others = QList<const Player *>()) const;
int getCardCount(bool include_equip) const;
QList<int> getPile(const char *pile_name) const;
QStringList getPileNames() const;
QString getPileName(int card_id) const;
bool pileOpen(const char *pile_name, const char *player) const;
void setPileOpen(const char *pile_name, const char *player);
void addHistory(const char *name, int times = 1);
void clearHistory(const char *name = "");
bool hasUsed(const char *card_class) const;
int usedTimes(const char *card_class) const;
int getSlashCount() const;
bool hasEquipSkill(const char *skill_name) const;
QList<const Skill *> getSkillList(bool include_equip = false, bool visible_only = true) const;
QList<const Skill *> getHeadSkillList(bool visible_only = true) const;
QList<const Skill *> getDeputySkillList(bool visible_only = true) const;
QList<const Skill *> getVisibleSkillList(bool include_equip = false) const;
QString getSkillDescription(bool inToolTip = true) const;
QString getHeadSkillDescription() const;
QString getDeputySkillDescription() const;
virtual bool isProhibited(const Player *to, const Card *card, const QList<const Player *> &others = QList<const Player *>()) const;
bool canSlashWithoutCrossbow(const Card *slash = NULL) const;
virtual bool isLastHandCard(const Card *card, bool contain = false) const = 0;
bool isJilei(const Card *card) const;
bool isLocked(const Card *card) const;
void setCardLimitation(const char *limit_list, const char *pattern, bool single_turn = false);
void removeCardLimitation(const char *limit_list, const char *pattern);
void clearCardLimitation(bool single_turn = false);
bool isCardLimited(const Card *card, Card::HandlingMethod method, bool isHandcard = false) const;
// just for convenience
void addQinggangTag(const Card *card);
void removeQinggangTag(const Card *card);
const Player *getLord(bool include_death = false) const; // a small function put here, simple but useful
void copyFrom(Player *p);
QList<const Player *> getSiblings() const;
QList<const Player *> getAliveSiblings() const;
bool hasShownSkill(const Skill *skill) const;
bool hasShownSkill(const char *skill_name) const;
bool hasShownSkills(const char *skill_names) const;
void preshowSkill(const char *skill_name);
bool inHeadSkills(const char *skill_name) const;
bool inHeadSkills(const Skill *skill) const;
bool inDeputySkills(const char *skill_name) const;
bool inDeputySkills(const Skill *skill) const;
const General *getActualGeneral1() const;
const General *getActualGeneral2() const;
QString getActualGeneral1Name() const;
QString getActualGeneral2Name() const;
void setActualGeneral1(const General *general);
void setActualGeneral2(const General *general);
void setActualGeneral1Name(const char *name);
void setActualGeneral2Name(const char *name);
bool hasShownGeneral1() const;
bool hasShownGeneral2() const;
void setGeneral1Showed(bool showed);
void setGeneral2Showed(bool showed);
bool hasShownOneGeneral() const;
bool hasShownAllGenerals() const;
void setSkillPreshowed(const char *skill, bool preshowed = true);
void setSkillsPreshowed(const char *falgs = "hd", bool preshowed = true);
bool hasPreshowedSkill(const char *name) const;
bool hasPreshowedSkill(const Skill *skill) const;
bool isHidden(const bool &head_general) const;
bool ownSkill(const char *skill_name) const;
bool ownSkill(const Skill *skill) const;
bool isFriendWith(const Player *player) const;
bool willBeFriendWith(const Player *player) const;
void setNext(Player *next);
void setNext(const char *next);
Player *getNext(bool ignoreRemoved = true) const;
QString getNextName() const;
Player *getLast(bool ignoreRemoved = true) const;
Player *getNextAlive(int n = 1, bool ignoreRemoved = true) const;
Player *getLastAlive(int n = 1, bool ignoreRemoved = true) const;
QList<const Player *> getFormation() const;
virtual QStringList getBigKingdoms(const char *reason, MaxCardsType::MaxCardsCount type = MaxCardsType::Min) const = 0;
};
%extend Player {
void setTag(const char *key, QVariant &value) {
$self->tag[key] = value;
}
QVariant getTag(const char *key) {
return $self->tag[key];
}
void removeTag(const char *tag_name) {
$self->tag.remove(tag_name);
}
};
class ServerPlayer: public Player {
public:
explicit ServerPlayer(Room *room);
QString objectName() const;
void kick();
void unicast(const char *message);
void drawCard(const Card *card);
Room *getRoom() const;
void broadcastSkillInvoke(const Card *card) const;
void broadcastSkillInvoke(const char *card_name) const;
int getRandomHandCardId() const;
const Card *getRandomHandCard() const;
void obtainCard(const Card *card, bool unhide = true);
void throwAllEquips();
void throwAllHandCards();
void throwAllHandCardsAndEquips();
void throwAllCards();
void bury();
void throwAllMarks(bool visible_only = true);
void clearOnePrivatePile(const char *pile_name);
void clearPrivatePiles();
int getMaxCards(MaxCardsType::MaxCardsCount type = MaxCardsType::Max) const;
void drawCards(int n, const char *reason = NULL);
bool askForSkillInvoke(const char *skill_name, const QVariant &data = QVariant());
bool askForSkillInvoke(const Skill *skill, const QVariant &data = QVariant());
QList<int> forceToDiscard(int discard_num, bool include_equip, bool is_discard = true);
QList<int> handCards() const;
virtual QList<const Card *> getHandcards() const;
QList<const Card *> getCards(const char *flags) const;
DummyCard *wholeHandCards() const;
bool hasNullification() const;
PindianStruct *pindianSelect(ServerPlayer *target, const char *reason, const Card *card1 = NULL);
bool pindian(PindianStruct *pd); //pd is deleted after this function
void turnOver();
void play(QList<Player::Phase> set_phases = QList<Player::Phase>());
bool changePhase(Player::Phase from, Player::Phase to);
QList<Player::Phase> &getPhases();
void skip(Player::Phase phase, bool sendLog = true);
void skip(bool sendLog = true);
void insertPhase(Player::Phase phase);
bool isSkipped(Player::Phase phase);
void gainMark(const char *mark, int n = 1);
void loseMark(const char *mark, int n = 1);
void loseAllMarks(const char *mark_name);
virtual void addSkill(const char *skill_name, bool head_skill = true);
virtual void loseSkill(const char *skill_name);
virtual void setGender(General::Gender gender);
void setAI(AI *ai);
AI *getAI() const;
AI *getSmartAI() const;
bool isOnline() const;
bool isOffline() const;
virtual int aliveCount(bool includeRemoved = true) const;
int getPlayerNumWithSameKingdom(const char *reason, const char *_to_calculate = NULL,
MaxCardsType::MaxCardsCount type = MaxCardsType::Max) const;
virtual int getHandcardNum() const;
virtual void removeCard(const Card *card, Place place);
virtual void addCard(const Card *card, Place place);
virtual bool isLastHandCard(const Card *card, bool contain = false) const;
void addVictim(ServerPlayer *victim);
QList<ServerPlayer *> getVictims() const;
void setNext(ServerPlayer *next);
ServerPlayer *getNext() const;
ServerPlayer *getNextAlive(int n = 1) const;
void startRecord();
void saveRecord(const char *filename);
// 3v3 methods
void addToSelected(const char *general);
QStringList getSelected() const;
//QString findReasonable(const QStringList &generals, bool no_unreasonable = false);
void clearSelected();
int getGeneralMaxHp() const;
virtual QString getGameMode() const;
QString getIp() const;
void introduceTo(ServerPlayer *player);
void marshal(ServerPlayer *player) const;
void addToPile(const char *pile_name, const Card *card, bool open = true, QList<ServerPlayer *> open_players = QList<ServerPlayer *>());
void addToPile(const char *pile_name, int card_id, bool open = true, QList<ServerPlayer *> open_players = QList<ServerPlayer *>());
void addToPile(const char *pile_name, QList<int> card_ids, bool open = true, QList<ServerPlayer *> open_players = QList<ServerPlayer *>());
void addToPile(const char *pile_name, QList<int> card_ids, bool open, QList<ServerPlayer *> open_players, CardMoveReason reason);
void gainAnExtraTurn();
void copyFrom(ServerPlayer *sp);
// static function
static bool CompareByActionOrder(ServerPlayer *a, ServerPlayer *b);
void showGeneral(bool head_general = true, bool trigger_event = true, bool sendLog = true);
void hideGeneral(bool head_general = true);
void removeGeneral(bool head_general = true);
void sendSkillsToOthers(bool head_skill = true);
void disconnectSkillsFromOthers(bool head_skill = true);
bool askForGeneralShow(bool one = true, bool refusable = false);
void notifyPreshow();
bool inSiegeRelation(const ServerPlayer *skill_owner, const ServerPlayer *victim) const;
bool inFormationRalation(ServerPlayer *teammate) const;
void summonFriends(const HegemonyMode::ArrayType type);
virtual QStringList getBigKingdoms(const char *reason, MaxCardsType::MaxCardsCount type = MaxCardsType::Min) const;
};
%extend ServerPlayer {
void speak(const char *msg) {
QString str = QString::fromUtf8(msg);
$self->getRoom()->speakCommand($self, str);
}
};
class ClientPlayer: public Player {
public:
explicit ClientPlayer(Client *client);
virtual QList<const Card *> getHandcards() const;
void setCards(const QList<int> &card_ids);
void setHandcardNum(int n);
virtual QString getGameMode() const;
virtual void setFlags(const char *flag);
virtual int aliveCount(bool includeRemoved = true) const;
virtual int getHandcardNum() const;
virtual void removeCard(const Card *card, Place place);
virtual void addCard(const Card *card, Place place);
virtual void addKnownHandCard(const Card *card);
virtual bool isLastHandCard(const Card *card, bool contain = false) const;
virtual void setMark(const char *mark, int value);
virtual QStringList getBigKingdoms(const char *reason, MaxCardsType::MaxCardsCount type = MaxCardsType::Min) const;
};
extern ClientPlayer *Self;
class CardMoveReason {
public:
int m_reason;
QString m_playerId; // the cause (not the source) of the movement, such as "lusu" when "dimeng", or "zhanghe" when "qiaobian"
QString m_targetId; // To keep this structure lightweight, currently this is only used for UI purpose.
// It will be set to empty if multiple targets are involved. NEVER use it for trigger condition
// judgement!!! It will not accurately reflect the real reason.
QString m_skillName; // skill that triggers movement of the cards, such as "longdang", "dimeng"
QString m_eventName; // additional arg such as "lebusishu" on top of "S_REASON_JUDGE"
CardMoveReason();
CardMoveReason(int moveReason, const char *playerId);
CardMoveReason(int moveReason, const char *playerId, const char *skillName, const char *eventName);
CardMoveReason(int moveReason, const char *playerId, const char *targetId, const char *skillName, const char *eventName);
static const int S_REASON_UNKNOWN = 0x00;
static const int S_REASON_USE = 0x01;
static const int S_REASON_RESPONSE = 0x02;
static const int S_REASON_DISCARD = 0x03;
static const int S_REASON_RECAST = 0x04; // ironchain etc.
static const int S_REASON_PINDIAN = 0x05;
static const int S_REASON_DRAW = 0x06;
static const int S_REASON_GOTCARD = 0x07;
static const int S_REASON_SHOW = 0x08;
static const int S_REASON_TRANSFER = 0x09;
static const int S_REASON_PUT = 0x0A;
//subcategory of use
static const int S_REASON_LETUSE = 0x11; // use a card when self is not current
//subcategory of response
static const int S_REASON_RETRIAL = 0x12;
//subcategory of discard
static const int S_REASON_RULEDISCARD = 0x13; // discard at one's Player::Discard for gamerule
static const int S_REASON_THROW = 0x23; /* gamerule(dying or punish)
as the cost of some skills */
static const int S_REASON_DISMANTLE = 0x33; // one throw card of another
//subcategory of gotcard
static const int S_REASON_GIVE = 0x17; // from one hand to another hand
static const int S_REASON_EXTRACTION = 0x27; // from another's place to one's hand
static const int S_REASON_GOTBACK = 0x37; // from placetable to hand
static const int S_REASON_RECYCLE = 0x47; // from discardpile to hand
static const int S_REASON_ROB = 0x57; // got a definite card from other's hand
static const int S_REASON_PREVIEWGIVE = 0x67; // give cards after previewing, i.e. Yiji & Miji
//subcategory of show
static const int S_REASON_TURNOVER = 0x18; // show n cards from drawpile
static const int S_REASON_JUDGE = 0x28; // show a card from drawpile for judge
static const int S_REASON_PREVIEW = 0x38; // Not done yet, plan for view some cards for self only(guanxing yiji miji)
static const int S_REASON_DEMONSTRATE = 0x48; // show a card which copy one to move to table
//subcategory of transfer
static const int S_REASON_SWAP = 0x19; // exchange card for two players
static const int S_REASON_OVERRIDE = 0x29; // exchange cards from cards in game
static const int S_REASON_EXCHANGE_FROM_PILE = 0x39;// exchange cards from cards moved out of game (for qixing only)
//subcategory of put
static const int S_REASON_NATURAL_ENTER = 0x1A; // a card with no-owner move into discardpile
// e.g. delayed trick enters discardpile
static const int S_REASON_REMOVE_FROM_PILE = 0x2A; // cards moved out of game go back into discardpile
static const int S_REASON_JUDGEDONE = 0x3A; // judge card move into discardpile
static const int S_REASON_CHANGE_EQUIP = 0x4A; // replace existed equip
static const int S_MASK_BASIC_REASON = 0x0F;
};
struct DamageStruct {
enum Nature {
Normal, // normal slash, duel and most damage caused by skill
Fire, // fire slash, fire attack and few damage skill (Yeyan, etc)
Thunder // lightning, thunder slash, and few damage skill (Leiji, etc)
};
DamageStruct();
DamageStruct(const Card *card, ServerPlayer *from, ServerPlayer *to, int damage = 1, Nature nature = Normal);
DamageStruct(const char *reason, ServerPlayer *from, ServerPlayer *to, int damage = 1, Nature nature = Normal);
ServerPlayer *from;
ServerPlayer *to;
const Card *card;
int damage;
Nature nature;
bool chain;
bool transfer;
bool by_user;
QString reason;
QString transfer_reason;
bool prevented;
QString getReason() const;
};
struct CardEffectStruct {
CardEffectStruct();
const Card *card;
ServerPlayer *from;
ServerPlayer *to;
bool nullified;
};
struct SlashEffectStruct {
SlashEffectStruct();
int jink_num;
const Card *slash;
const Card *jink;
ServerPlayer *from;
ServerPlayer *to;
int drank;
DamageStruct::Nature nature;
bool nullified;
};
struct CardUseStruct {
enum CardUseReason {
CARD_USE_REASON_UNKNOWN = 0x00,
CARD_USE_REASON_PLAY = 0x01,
CARD_USE_REASON_RESPONSE = 0x02,
CARD_USE_REASON_RESPONSE_USE = 0x12
} m_reason;
CardUseStruct();
CardUseStruct(const Card *card, ServerPlayer *from, QList<ServerPlayer *> to, bool isOwnerUse = true);
CardUseStruct(const Card *card, ServerPlayer *from, ServerPlayer *target, bool isOwnerUse = true);
bool isValid(const char *pattern) const;
void parse(const char *str, Room *room);
const Card *card;
ServerPlayer *from;
QList<ServerPlayer *> to;
bool m_isOwnerUse;
bool m_addHistory;
bool m_isHandcard;
QStringList nullified_list;
};
struct CardsMoveStruct {
CardsMoveStruct();
CardsMoveStruct(const QList<int> &ids, Player *from, Player *to, Player::Place from_place, Player::Place to_place, CardMoveReason reason);
CardsMoveStruct(const QList<int> &ids, Player *to, Player::Place to_place, CardMoveReason reason);
CardsMoveStruct(int id, Player *from, Player *to, Player::Place from_place, Player::Place to_place, CardMoveReason reason);
CardsMoveStruct(int id, Player *to, Player::Place to_place, CardMoveReason reason);
QList<int> card_ids;
Player::Place from_place, to_place;
QString from_player_name, to_player_name;
QString from_pile_name, to_pile_name;
Player *from, *to;
CardMoveReason reason;
bool open; // helper to prevent sending card_id to unrelevant clients
bool is_last_handcard;
Player::Place origin_from_place, origin_to_place;
Player *origin_from, *origin_to;
QString origin_from_pile_name, origin_to_pile_name; //for case of the movement transitted
bool isRelevant(const Player *player);
};
struct CardsMoveOneTimeStruct {
QList<int> card_ids;
QList<Player::Place> from_places;
Player::Place to_place;
CardMoveReason reason;
Player *from, *to;
QStringList from_pile_names;
QString to_pile_name;
QList<Player::Place> origin_from_places;
Player::Place origin_to_place;
Player *origin_from, *origin_to;
QStringList origin_from_pile_names;
QString origin_to_pile_name; //for case of the movement transitted
QList<bool> open; // helper to prevent sending card_id to unrelevant clients
bool is_last_handcard;
};
struct DyingStruct {
DyingStruct();
ServerPlayer *who; // who is ask for help
DamageStruct *damage; // if it is NULL that means the dying is caused by losing hp
};
struct DeathStruct {
DeathStruct();
ServerPlayer *who; // who is dead
DamageStruct *damage; // if it is NULL that means the dying is caused by losing hp
};
struct RecoverStruct {
RecoverStruct();
int recover;
ServerPlayer *who;
const Card *card;
};
struct PindianStruct {
PindianStruct();
bool isSuccess() const;
ServerPlayer *from;
ServerPlayer *to;
const Card *from_card;
const Card *to_card;
int from_number;
int to_number;
QString reason;
bool success;
};
struct JudgeStruct {
JudgeStruct();
bool isGood() const;
bool isBad() const;
bool isEffected() const;
void updateResult();
bool isGood(const Card *card) const; // For AI
ServerPlayer *who;
const Card *card;
QString pattern;
bool good;
QString reason;
bool time_consuming;
bool negative;
bool play_animation;
};
struct PhaseChangeStruct {
PhaseChangeStruct();
Player::Phase from;
Player::Phase to;
};
struct CardResponseStruct {
CardResponseStruct();
CardResponseStruct(const Card *card);
CardResponseStruct(const Card *card, ServerPlayer *who);
CardResponseStruct(const Card *card, bool isUse);
CardResponseStruct(const Card *card, ServerPlayer *who, bool isUse);
const Card *m_card;
ServerPlayer *m_who;
bool m_isUse;
bool m_isRetrial;
bool m_isHandcard;
};
struct PlayerNumStruct {
PlayerNumStruct();
PlayerNumStruct(int num, const char *toCalculate);
PlayerNumStruct(int num, const char *toCalculate, MaxCardsType::MaxCardsCount type);
PlayerNumStruct(int num, const char *toCalculate, MaxCardsType::MaxCardsCount type, const char *reason);
MaxCardsType::MaxCardsCount m_type;
int m_num;
QString m_toCalculate;
QString m_reason;
};
struct RoomInfoStruct {
const QString Name;
const QString GameMode;
const QSet<QString> BanPackages;
const int OperationTimeout;
const int NullificationCountDown;
const bool RandomSeat;
const bool EnableCheat;
const bool FreeChoose;
const bool ForbidAddingRobot;
const bool DisableChat;
const bool FirstShowingReward;
const bool RequirePassword;
};
extern RoomInfoStruct ServerInfo;
enum TriggerEvent {
NonTrigger,
GameStart,
TurnStart,
EventPhaseStart,
EventPhaseProceeding,
EventPhaseEnd,
EventPhaseChanging,
EventPhaseSkipping,
ConfirmPlayerNum, // hongfa only
DrawNCards,
AfterDrawNCards,
PreHpRecover,
HpRecover,
PreHpLost,
HpChanged,
MaxHpChanged,
PostHpReduced,
EventLoseSkill,
EventAcquireSkill,
StartJudge,
AskForRetrial,
FinishRetrial,
FinishJudge,
PindianVerifying,
Pindian,
TurnedOver,
ChainStateChanged,
RemoveStateChanged,
ConfirmDamage, // confirm the damage's count and damage's nature
Predamage, // trigger the certain skill -- jueqing
DamageForseen, // the first event in a damage -- kuangfeng dawu
DamageCaused, // the moment for -- qianxi..
DamageInflicted, // the moment for -- tianxiang..
PreDamageDone, // before reducing Hp
DamageDone, // it's time to do the damage
Damage, // the moment for -- lieren..
Damaged, // the moment for -- yiji..
DamageComplete, // the moment for trigger iron chain
Dying,
QuitDying,
AskForPeaches,
AskForPeachesDone,
Death,
BuryVictim,
BeforeGameOverJudge,
GameOverJudge,
GameFinished,
SlashEffected,
SlashProceed,
SlashHit,
SlashMissed,
JinkEffect,
CardAsked,
CardResponded,
BeforeCardsMove, // sometimes we need to record cards before the move
CardsMoveOneTime,
PreCardUsed,
CardUsed,
TargetChoosing, //distinguish "choose target" and "confirm target"
TargetConfirming,
TargetChosen,
TargetConfirmed,
CardEffect,
CardEffected,
PostCardEffected,
CardFinished,
TrickCardCanceling,
ChoiceMade,
StageChange, // For hulao pass only
FetchDrawPileCard, // For miniscenarios only
TurnBroken, // For the skill 'DanShou'. Do not use it to trigger events
GeneralShown, // For Official Hegemony mode
GeneralHidden, // For Official Hegemony mode
GeneralRemoved, // For Official Hegemony mode
DFDebut,
NumOfEvents
};
class Card: public QObject {
public:
// enumeration type
enum Suit { Spade, Club, Heart, Diamond, NoSuitBlack, NoSuitRed, NoSuit, SuitToBeDecided = -1 };
enum Color { Red, Black, Colorless };
enum HandlingMethod { MethodNone, MethodUse, MethodResponse, MethodDiscard, MethodRecast, MethodPindian };
static const Suit AllSuits[4];
// card types
enum CardType { TypeSkill, TypeBasic, TypeTrick, TypeEquip };
// constructor
Card(Suit suit, int number, bool target_fixed = false);
// property getters/setters
QString getSuitString() const;
bool isRed() const;
bool isBlack() const;
int getId() const;
virtual void setId(int id);
int getEffectiveId() const;
int getNumber() const;
virtual void setNumber(int number);
QString getNumberString() const;
Suit getSuit() const;
virtual void setSuit(Suit suit);
bool sameColorWith(const Card *other) const;
Color getColor() const;
QString getFullName(bool include_suit = false) const;
QString getLogName() const;
QString getName() const;
QString getSkillName(bool removePrefix = true) const;
virtual void setSkillName(const char *skill_name);
QString getDescription(bool inToolTip = true) const;
virtual bool isMute() const;
virtual bool willThrow() const;
virtual bool canRecast() const;
virtual bool hasPreAction() const;
virtual Card::HandlingMethod getHandlingMethod() const;
virtual void setFlags(const char *flag) const;
//virtual void setFlags(const QStringList &fs);
bool hasFlag(const char *flag) const;
virtual void clearFlags() const;
virtual QString getPackage() const;
virtual QString getClassName() const;
virtual bool isVirtualCard() const;
virtual bool isEquipped() const;
virtual QString getCommonEffectName() const;
virtual bool match(const char *pattern) const;
virtual void addSubcard(int card_id);
virtual void addSubcard(const Card *card);
virtual QList<int> getSubcards() const;
virtual void clearSubcards();
virtual QString subcardString() const;
virtual void addSubcards(const QList<const Card *> &cards);
virtual void addSubcards(const QList<int> &subcards_list);
virtual int subcardsLength() const;
virtual QString getType() const = 0;
virtual QString getSubtype() const = 0;
virtual CardType getTypeId() const = 0;
virtual bool isNDTrick() const;
// card target selection
virtual bool targetFixed() const;
virtual bool targetsFeasible(const QList<const Player *> &targets, const Player *Self) const;
// @todo: the following two functions should be merged into one.
virtual bool targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self) const;
virtual bool targetFilter(const QList<const Player *> &targets, const Player *to_select, const Player *Self, int &maxVotes) const;
virtual bool isAvailable(const Player *player) const;
virtual const Card *getRealCard() const;
virtual const Card *validate(CardUseStruct &cardUse) const;
virtual const Card *validateInResponse(ServerPlayer *user) const;
virtual void doPreAction(Room *room, const CardUseStruct &card_use) const;
virtual void onUse(Room *room, const CardUseStruct &card_use) const;
virtual void use(Room *room, ServerPlayer *source, QList<ServerPlayer *> &targets) const;
virtual void onEffect(const CardEffectStruct &effect) const;
virtual bool isCancelable(const CardEffectStruct &effect) const;
virtual QStringList checkTargetModSkillShow(const CardUseStruct &use) const;
virtual QString showSkill() const;