Initial commit

This commit is contained in:
WatermelonModders
2022-05-31 12:35:46 -04:00
commit fc5cb0c32c
4097 changed files with 447075 additions and 0 deletions
@@ -0,0 +1,24 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHOOSE_ENTITIES_H_
#define CHOOSE_ENTITIES_H_
void choose_one_entity(struct conn_client_s *c, struct chooseentities_s *e);
void choose_entities(struct conn_client_s *c, struct chooseentities_s *e);
#endif
+23
View File
@@ -0,0 +1,23 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHOOSE_OPTION_H_
#define CHOOSE_OPTION_H_
int choose_option(struct conn_client_s *c, struct chooseoption_s *opt);
#endif
+50
View File
@@ -0,0 +1,50 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMON_H_
#define COMMON_H_
const struct ent_s *find_entity(const char *name, const int nname);
struct powerhistory_tag_s *add_tag(struct powerhistory_tag_s **dst, const int key, const int value);
struct powerhistory_game_entity_s *add_game_entity(struct powerhistory_game_entity_s **dst, struct powerhistory_tag_s *tag, const int id);
struct powerhistory_tag_s *default_tags(struct card_s *card, const struct ent_s *ent, int zone_override);
void add_tagchange(struct powerhistory_data_s **dst, u64 key, u64 value, u64 id);
void add_powerstart(struct powerhistory_data_s **dst, u64 type, u64 index, u64 source, u64 target, char *card_id, int ncard_id);
void add_tagschange(struct powerhistory_data_s **dst, const struct ent_s *ent, u64 id);
void add_player(struct powerhistory_player_s **dst, u64 id, u64 bhi, u64 blo, u64 cardback, struct powerhistory_game_entity_s *ent);
void add_game_start(struct powerhistory_creategame_s **dst, struct powerhistory_game_entity_s *ge, struct powerhistory_player_s *p);
void add_ph_data(struct powerhistory_data_s **dst, struct powerhistory_entity_s *full, struct powerhistory_creategame_s *cg);
void add_ph_data(struct powerhistory_data_s **dst, struct powerhistory_entity_s *full, struct powerhistory_creategame_s *cg);
void add_ph(struct powerhistory_s **dst, struct powerhistory_data_s *data);
void add_packet(struct packet_s **dst, void *ph, enum packet_e n);
void add_hide(struct powerhistory_data_s **dst, u64 entity, u64 zone);
void add_powerend(struct powerhistory_data_s **dst);
void add_full_entity(struct powerhistory_entity_s **full, struct powerhistory_tag_s *tags, u64 id, const char *name, const int nname);
void add_ph_data_show(struct powerhistory_data_s **dst, struct powerhistory_entity_s *show);
void add_meta(struct powerhistory_data_s **dst, u64 type, u64 d, u64 infoid);
void add_info(struct powerhistory_info_s **dst, u64 infoid);
void add_meta_info(struct powerhistory_data_s **dst, u64 type, u64 d, struct powerhistory_info_s *info);
void add_ph_data_full(struct powerhistory_data_s **dst, struct powerhistory_entity_s *full);
void bin_dump(char *buf, const int len);
int random_number(int max);
void register_turntimer(struct conn_client_s *c);
extern struct ht_s **clients;
extern struct ev_loop *loop;
#endif
+270
View File
@@ -0,0 +1,270 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DECK_H_
#define DECK_H_
#define DECK_INIT 0x1
#define G_P1_CARDS_CHOSEN 0x1
#define G_P2_CARDS_CHOSEN 0x2
#define MAX_BOSS 2
#define MAX_BOARD 7
#define LIST_ADD(list__, item__, src__)\
item__ = malloc(sizeof(*item__));\
item__->card = src__;\
item__->next = NULL;\
if(list__ != NULL && (list__)->tail) {\
(list__)->tail->next = item__;\
(list__)->tail = item__;\
} else {\
(list__) = item__;\
(list__)->tail = item__;\
}
#define LIST_ADD_LINK(list__, src__)\
list__ = src__;
enum deck_mod_e {
DECK_MODIFIER_ATTACK = 1,
DECK_MODIFIER_HEALTH,
DECK_MODIFIER_ATTACK_CHARGE,
DECK_MODIFIER_ATTACK_BEAST,
};
enum deck_free_e {
FREE_DECK_ATTACHMENT = (1<<1),
FREE_CARD_CHILDREN = (1<<2),
FREE_CARD_EXPIRE = (1<<3),
};
struct card_expire_s {
int turn;
int attack;
int frozen;
int destroy;
int magic_immunity;
const char *attachment;
struct card_expire_s *next;
};
struct attachment_list_s {
const char *name;
enum flags_e group;
struct attachment_list_s *next;
};
struct card_link_s {
int id;
const char *name;
struct card_link_s *next, *tail;
};
struct card_s {
struct hs_holder_s *parent;
int controller;
int id;
struct flags_s state;
const char *attachment; // name of CARD_ATTACHMENT
int attached_to; // only for CARD_ATTACHMENT
struct card_link_s *attached_children; // children
const struct ent_s *entity;
int zone_position;
int total_health;
int health;
int default_health;
int buff_health;
int attack;
int default_attack;
int cost;
int default_cost;
int cardtype;
int durability;
int maxdurability;
int armor;
int actions_number;
int spellpower;
struct {
unsigned int flags;
struct card_list_s *card;
} target;
struct {
int damage;
int heal;
} receive;
struct {
char level;
int experience;
} boss;
int linked;
struct card_expire_s *expire;
int priority_override;
int total_plays; // total number of plays with this card, zero'd when returned to hand
int turn_plays; // total number of plays since turn started
};
struct deck_s {
struct hs_holder_s *parent;
u64 bnet_hi;
int controller;
int mana;
int mana_used;
int spellpower;
int handposition;
int ncards;
struct card_s **cards;
struct {
int attack;
int attack_charge;
int attack_beast;
int health;
} modifiers;
struct card_s *hero;
struct card_s *heropower;
struct card_s *heroweapon;
int board_position[MAX_BOARD];
struct attachment_list_s *attachments;
int fatigue;
int gameover;
unsigned int flags;
};
struct card_list_s {
struct card_s *card;
struct card_list_s *tail, *next;
};
struct game_s {
int entity_id;
unsigned int flags;
int turn;
int maxentity_id;
struct ev_timer turntimer, force_next_turn;
};
struct hs_holder_s {
struct conn_client_s *client;
struct deck_s *deck;
struct deck_s *deck_copy;
int id;
int entity_id;
int held_card;
int arroworigin;
int choose_one;
struct {
int accessible;
struct deck_s *deck;
struct deck_s *deck_copy;
struct conn_client_s *client;
} opponent;
struct game_s *game;
unsigned int flags;
};
void holder_free(struct hs_holder_s *h);
int append_decks(struct conn_client_s *p1, struct conn_client_s *p2);
int append_game(struct conn_client_s *p1, struct conn_client_s *p2);
void card_to_deck(struct card_s *card);
struct card_s *draw_random_card(struct deck_s *deck, int entity_id, int zone_position);
struct card_s *new_card(const int id, const char *name, int controller);
void card_used_reorder(struct deck_s *deck, u64 id);
void cards_reorder_board_opponent(struct powerhistory_data_s **data, struct deck_s *deck);
void cards_reorder_board_owner(struct deck_s *deck, u64 held, u64 position);
struct card_s *card_get(struct deck_s *deck, struct deck_s *opponent, const int id);
struct card_list_s *cards_get_board(struct deck_s *deck, struct deck_s *opponent, int hero, int exclude, int magic_immunity, int boss);
struct card_s *card_get_hero(struct deck_s *deck);
void cards_reorder_hand_owner(struct deck_s *deck, u64 id);
void cards_reorder_hand_opponent(struct powerhistory_data_s **data, struct deck_s *deck);
void cards_board_destroyed_reorder(struct deck_s *deck, int position);
int game_attack(struct hs_holder_s *p, struct card_s *attacker, struct card_s *defender);
int update_resources(struct deck_s *deck, struct card_s *attacker, int refresh);
void cards_unset_flag(struct deck_s *deck, enum flags_e flags);
void card_set_exhausted(struct card_s *card);
int cards_board_last(struct deck_s *deck);
struct card_s *add_new_card(struct game_s *game, struct deck_s *deck, int index, const char *card, unsigned int flags);
int zone_position_last(struct deck_s *deck);
void unset_mechanics_flags(struct hs_holder_s *p);
void cards_reorder(struct hs_holder_s *p, struct deck_s *deck, struct card_s *attacker, u64 position, int summoned);
int cards_get_board_count(struct deck_s *deck, struct deck_s *opponent, int hero, int exclude);
void decks_copy(struct hs_holder_s *p);
void decks_swap(struct hs_holder_s *p);
void deck_modifier(struct hs_holder_s *p, struct deck_s *deck, struct card_s *attacker, enum deck_mod_e key, int value);
void deck_apply_modifiers(struct hs_holder_s *p, struct deck_s *deck, struct card_s *attacker, u64 position);
void card_destroy(struct card_s *card, struct deck_s *deck, int to_hand);
void deck_destroy_modifier(struct deck_s *deck, struct card_s *defender);
struct card_s *cards_get_hand_random(struct deck_s *deck);
void copy_card(struct card_s **dst, struct card_s *src);
struct card_list_s *cards_get_random(struct deck_s *deck, int number, struct card_s *attacker, int zone);
int cards_get_board_count_flag(struct deck_s *deck, struct card_s *card, int f);
int cards_get_board_flag(struct deck_s *deck, int f, int exclude);
void card_apply_attachments(struct hs_holder_s *p, struct deck_s *deck, struct card_s *card);
void deck_add_attachment(struct deck_s *deck, const char *attachment, enum flags_e f);
void cards_apply_attachment(struct hs_holder_s *p, struct deck_s *deck, struct card_s *attacker, enum flags_e f);
int card_count_attachment(struct deck_s *deck, struct deck_s *opponent, struct card_s *card, const char *name);
void add_single_attachment(struct hs_holder_s *p, struct deck_s *deck, struct card_s *attacker, struct card_s *defender);
void card_remove_attachment(struct deck_s *deck, struct deck_s *opponent, struct card_s *card, const char *name);
struct card_s *card_get_board_zoneposition(struct deck_s *deck, u64 position);
void card_apply_attachment(struct hs_holder_s *p, struct deck_s *deck, struct card_s *dst, const char *attachment);
void cards_adjacent(struct hs_holder_s *p, struct deck_s *deck);
int deck_get_taunts(struct deck_s *deck);
void card_discard_by_name(struct hs_holder_s *p, struct card_s *card, const char *name);
struct card_s *card_by_name(struct hs_holder_s *p, struct deck_s *deck, const char *name, int f);
struct card_list_s *cards_get_board_boss(struct deck_s *deck);
void reset_turn_plays(struct deck_s *deck);
void card_free(struct card_s *card, unsigned int flags);
int card_deck_count(struct deck_s *deck);
void deck_free(struct deck_s *deck, unsigned int flags);
struct card_s *card_get_levelup_boss(struct deck_s *deck, struct card_s *card);
int cards_count(struct card_list_s *l);
struct card_s *card_random(struct card_list_s *l);
struct card_s *draw_first_boss(struct deck_s *deck);
struct card_list_s *cards_get_hand(struct deck_s *deck);
int board_count_by_name(struct deck_s *deck, const char *name);
void cards_dump(struct deck_s *deck, struct deck_s *opponent);
struct card_list_s *cards_by_name(struct hs_holder_s *p, struct deck_s *deck, const char *name, int f);
#endif
@@ -0,0 +1,24 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENTITY_CHOICES_H_
#define ENTITY_CHOICES_H_
struct entitychoices_s *prepare_choices(struct deck_s *deck, int player_id);
struct entitychoices_s *chooseone_choices(struct card_list_s *defenders, int player_id, int attacker_id);
#endif
+56
View File
@@ -0,0 +1,56 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLAGS_H_
#define FLAGS_H_
#define MAX_FLAGS_ARRAY 16
#define LL_BITS 64
enum flag_type_e {
F_ADDED = 1,
F_REMOVED = 2,
};
struct flag_pr_s {
enum flags_e flag;
int priority;
enum flag_type_e type;
struct card_s *parent_card;
};
// 64 * MAX_FLAGS_ARRAY flags
struct flags_s {
unsigned long long nibble[MAX_FLAGS_ARRAY];
};
enum flags_action_e {
FLAG_SET = 0,
FLAG_UNSET = 1,
FLAG_ISSET = 2,
FLAG_DUMP = 3,
};
int flag(struct flags_s *flags, enum flags_e src, enum flags_action_e action);
int flags_copy(struct flags_s *dst, const struct flags_s *src);
void flags_diff(struct flags_s *old, struct flags_s *new,
struct flag_pr_s ***src_added, int *nsrc_added,
struct flag_pr_s ***src_removed, int *nsrc_removed,
struct card_s *parent_card);
int flag_get(struct flags_s *flags, int **f);
#endif
+67
View File
@@ -0,0 +1,67 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAME_H_
#define GAME_H_
#define LOG_MECHANICS "{Mechanics}: "
#define HM_GAMESERVER
#include <hsl_cardname.h>
#include <levelup.h>
#include <sections.h>
#include <json.h>
#include <hmbase.h>
#include <async_client.h>
#include <flag_def.h>
#include <proto.h>
#include <common.h>
#include <hs.h>
#include <deck.h>
#include <choose_entities.h>
#include <entity_choices.h>
#include <choose_option.h>
#include <game_options.h>
#include <mechanics.h>
#include <net.h>
#include <level.h>
struct packet_s *game_reply(struct hs_holder_s *p, struct chooseoption_s *opt, struct card_s *attacker, int player);
int game_attack_aoe(struct hs_holder_s *p, struct card_s *attacker, struct card_list_s *defenders, struct card_s **fake_levelup);
void user_ui(struct conn_client_s *c, struct userui_s *u);
int game(struct conn_client_s *c, struct chooseoption_s *opt);
void game_free(struct game_s *g);
void next_turn(struct conn_client_s *c, struct hs_holder_s *p/*, struct chooseoption_s *opt*/);
void mechanics_attack(struct conn_client_s *c, struct chooseoption_s *opt, struct card_s *attacker, struct card_list_s *defenders);
void mechanics_next_turn(struct conn_client_s *c, struct hs_holder_s *p);
void mechanics_put_card_onboard(struct conn_client_s *c, u64 position, struct card_s *attacker, int summoned, struct card_list_s **defenders, struct chooseoption_s *opt, struct deck_s *deck);
void mechanics_attack_aoe(struct conn_client_s *c, u64 position, struct card_s *attacker, struct card_list_s **defenders, struct card_s **fake_levelup);
void mechanics_buff(struct conn_client_s *c, struct chooseoption_s *opt, struct card_s *attacker, struct card_list_s **defenders);
void mechanics_summon(struct conn_client_s *c, struct chooseoption_s *opt, struct card_s *attacker, struct card_list_s **defenders);
void mechanics_draw_card(struct conn_client_s *c, struct chooseoption_s *opt, struct card_s *attacker, int cards, struct card_list_s **defenders);
void mechanics_expire(int game_turn, struct card_s *card, enum expire_e key, int value, const char *name);
void force_expire(struct hs_holder_s *p, struct deck_s *deck, struct card_s *card);
void mechanics_attack_swipe(struct conn_client_s *c, u64 position, struct card_s *attacker, struct card_list_s **defenders);
int entity_attack(struct hs_holder_s *p, struct card_s *attacker, struct card_s *defender);
void put_card_onboard(struct conn_client_s *c, struct hs_holder_s *p, struct chooseoption_s *opt);
void power_attack(struct conn_client_s *c, struct hs_holder_s *p, struct chooseoption_s *opt);
extern struct hm_log_s *lg;
#endif
+24
View File
@@ -0,0 +1,24 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAME_OPTIONS_H_
#define GAME_OPTIONS_H_
int set_options(struct deck_s *deck, struct deck_s *opponent, char *buffer, char *endbuffer, int turn);
int set_options_cards(struct card_list_s *cl, char *buffer, char *endbuffer, int turn);
#endif
+25
View File
@@ -0,0 +1,25 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HS_H_
#define HS_H_
void hs(struct conn_client_s *c, const char *buf, const int len);
int game_start(struct conn_client_s *c);
void handshake_dump(struct handshake_s *h);
#endif
+57
View File
@@ -0,0 +1,57 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CARDNAME_H_
#define CARDNAME_H_
#define CN_BOAR "CS2_boar"
#define CN_VULTURE "CS2_237"
#define CN_BLACK_HOLE "EX1_312"
#define CN_DEMONIC_CONVERSION "OG_101"
#define CN_EIDOLON "AT_023"
#define CN_COUNTER_HELIX "EX1_400"
#define CN_CULLING_BLADE "CS2_108"
#define CN_WARCRY "NEW1_036"
#define CN_GODS_WRATH "EX1_259"
#define CN_FORKED_LIGHTNING "EX1_251"
#define CN_DRAGONS_BREATH "BRM_003"
#define CN_ENRAGE "CS2_011"
#define CN_REQUIEM_OF_SOULS "EX1_303"
#define CN_SHADOW_FIEND "CS2_118"
#define CN_NECROMASTERY "EX1_596e"
#define CN_LAGUNA_BLADE "AT_001"
#define CN_WOUNDED "AT_039e"
#define CN_SWIPES "CS2_012"
#define CN_GODS_STRENGTH "OG_223"
#define CN_URSA "EX1_165t2"
#define CN_SVEN "EX1_383"
#define CN_ECHO_SABRE "LOE_118"
#define CN_DIVINE_RAPIER "CS2_097"
#define CN_DIVINE_RAPIER_BONUS "FP1_020e"
#define CN_LINA "AT_018"
#define CN_ZEUS "EX1_559"
#define CN_ENIGMA "CS2_065"
#define CN_AXE "NEW1_011"
#define CN_STORMWIND_CHAMP "CS2_222"
#define CN_STORMWIND_CHAMP_BONUS "CS2_222o"
#define CN_SKELETON "NAX4_03H"
#define CN_TINY "EX1_105"
#define CN_WISP_BONUS "NAX12_04e"
#define CN_WISP "CS2_231"
#define CN_DESOLATOR_BONUS "LOEA06_03e"
#endif
+25
View File
@@ -0,0 +1,25 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LEVEL_H_
#define LEVEL_H_
#define LEVEL_1 "CS2_103e2"
#define LEVEL_2 "EX1_178ae"
#define LEVEL_3 "CS1_129e"
#endif
+32
View File
@@ -0,0 +1,32 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MECHANICS_H_
#define MECHANICS_H_
enum expire_e {
EXPIRE_ATTACK = 1,
EXPIRE_FROZEN = 2,
EXPIRE_DESTROY = 3,
EXPIRE_ATTACHMENT = 4,
EXPIRE_MAGIC_IMMUNITY = 5,
};
void mechanics_expire(int game_turn, struct card_s *card, enum expire_e key, int value, const char *attachment);
void mechanics_expired(struct hs_holder_s *p, struct deck_s *deck);
#endif
+47
View File
@@ -0,0 +1,47 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NET_H_
#define NET_H_
enum nettype_e {
NET_BUFF = 1,
NET_BUFFAOE,
NET_PUTONBOARD,
NET_ATTACK,
NET_SPELL,
NET_SPELLAOE,
NET_NEXTTURN,
NET_SPELLHP_DAMAGE,
};
void net_card_flags(struct powerhistory_data_s **data, struct deck_s *deck_old, struct deck_s *deck_new,
struct deck_s *opp_old, struct deck_s *opp_new, struct card_list_s *src, struct hs_holder_s *p, int target_player, int nettype);
struct packet_s *net_attack(struct conn_client_s *c, struct chooseoption_s *opt, struct card_s *attacker, struct card_s *defender, int target_player);
int net_send(struct conn_client_s *c, struct packet_s *packet);
int net_send_options(struct conn_client_s *c, struct deck_s *deck, struct deck_s *opponent, int turn);
int net_send_cl_options(struct conn_client_s *c, struct card_list_s *cl, int turn);
struct packet_s *net_next_turn(struct conn_client_s *c, struct card_s **drawn_card, int *zoneposition);
struct packet_s *net_card_onboard(struct hs_holder_s *p, struct chooseoption_s *opt, struct card_s *attacker, int player);
struct packet_s *net_spell_aoe(struct conn_client_s *c, struct chooseoption_s *opt, int player, struct card_s *attacker);
struct packet_s *net_buff(struct conn_client_s *c, struct chooseoption_s *opt, int player, struct card_s *attacker, struct card_list_s *defenders);
struct packet_s *net_spell(struct conn_client_s *c, struct chooseoption_s *opt, int player, struct card_s *attacker, struct card_list_s *defenders, struct card_s *fake_levelup);
struct packet_s *net_spell_hp_damage(struct conn_client_s *c, struct card_list_s *defenders, struct card_s *attacker);
void net_send_turntimer(struct conn_client_s *c, int seconds, int turn, int show);
struct packet_s *net_game_over(struct hs_holder_s *p, int loser);
#endif
@@ -0,0 +1,35 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHOOSEENTITIES_H_
#define CHOOSEENTITIES_H_
struct chooseentities_ent_s {
u64 entity;
struct chooseentities_ent_s *next;
};
struct chooseentities_s {
u64 id;
int nentity;
struct chooseentities_ent_s *entity;
};
void chooseentities_free(struct chooseentities_s *c);
void *chooseentities_deserialize(char **dst, const char *maxdst);
#endif
+50
View File
@@ -0,0 +1,50 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENT_S_
#define ENT_S_
#include <flag_def.h>
#include <flags.h>
#define MAX_PROPERTIES 16
struct ent_property_s {
int key;
int value;
};
struct ent_s {
const char *name;
int nname;
int nprop;
const char *level2;
const char *level3;
const char *desc;
struct flags_s flags;
const char *attachment;
struct ent_property_s p[MAX_PROPERTIES];
};
extern struct ent_s entities[MAX_ENTITIES];
void entities_init();
void entities_init2();
#endif
@@ -0,0 +1,42 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENTITYCHOICES_H_
#define ENTITYCHOICES_H_
struct entitychoices_entities_s {
u64 entity;
struct entitychoices_entities_s *next;
};
struct entitychoices_s {
u64 id;
u64 type;
u64 countmin;
u64 countmax;
u64 source;
u64 player_id;
struct entitychoices_entities_s *entities;
};
void entitychoices_free(struct entitychoices_s *ec);
int entitychoices_serialize(void *ep, char **dst, const char *maxdst);
void entitychoices_dump(struct entitychoices_s *es);
#endif
+250
View File
@@ -0,0 +1,250 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TAG_H_
#define TAG_H_
enum gametag_e {
TAG_SCRIPT_DATA_NUM_1 = 2,
TAG_SCRIPT_DATA_NUM_2 = 3,
TAG_SCRIPT_DATA_ENT_1 = 4,
TAG_SCRIPT_DATA_ENT_2 = 5,
MISSION_EVENT = 6,
TIMEOUT = 7,
TURN_START = 8,
TURN_TIMER_SLUSH = 9,
PREMIUM = 12,
GOLD_REWARD_STATE = 13,
PLAYSTATE = 17,
LAST_AFFECTED_BY = 18,
STEP = 19,
TURN = 20,
FATIGUE = 22,
CURRENT_PLAYER = 23,
FIRST_PLAYER = 24,
RESOURCES_USED = 25,
RESOURCES = 26,
HERO_ENTITY = 27,
MAXHANDSIZE = 28,
STARTHANDSIZE = 29,
PLAYER_ID = 30,
TEAM_ID = 31,
TRIGGER_VISUAL = 32,
RECENTLY_ARRIVED = 33,
PROTECTING = 34,
PROTECTED = 35,
DEFENDING = 36,
PROPOSED_DEFENDER = 37,
ATTACKING = 38,
PROPOSED_ATTACKER = 39,
ATTACHED = 40,
EXHAUSTED = 43,
DAMAGE = 44,
HEALTH = 45,
ATK = 47,
COST = 48,
ZONE = 49,
CONTROLLER = 50,
OWNER = 51,
DEFINITION = 52,
ENTITY_ID = 53,
HISTORY_PROXY = 54,
COPY_DEATHRATTLE = 55,
ELITE = 114,
MAXRESOURCES = 176,
CARD_SET = 183,
CARDTEXT_INHAND = 184,
CARDNAME = 185,
CARD_ID = 186,
DURABILITY = 187,
SILENCED = 188,
WINDFURY = 189,
TAUNT = 190,
STEALTH = 191,
SPELLPOWER = 192,
DIVINE_SHIELD = 194,
CHARGE = 197,
NEXT_STEP = 198,
CLASS = 199,
CARDRACE = 200,
FACTION = 201,
CARDTYPE = 202,
RARITY = 203,
STATE = 204,
SUMMONED = 205,
FREEZE = 208,
ENRAGED = 212,
OVERLOAD = 215,
LOYALTY = 216,
DEATHRATTLE = 217,
BATTLECRY = 218,
SECRET = 219,
COMBO = 220,
CANT_HEAL = 221,
CANT_DAMAGE = 222,
CANT_SET_ASIDE = 223,
CANT_REMOVE_FROM_GAME = 224,
CANT_READY = 225,
CANT_EXHAUST = 226,
CANT_ATTACK = 227,
CANT_TARGET = 228,
CANT_DESTROY = 229,
CANT_DISCARD = 230,
CANT_PLAY = 231,
CANT_DRAW = 232,
INCOMING_HEALING_MULTIPLIER = 233,
INCOMING_HEALING_ADJUSTMENT = 234,
INCOMING_HEALING_CAP = 235,
INCOMING_DAMAGE_MULTIPLIER = 236,
INCOMING_DAMAGE_ADJUSTMENT = 237,
INCOMING_DAMAGE_CAP = 238,
CANT_BE_HEALED = 239,
CANT_BE_DAMAGED = 240,
CANT_BE_SET_ASIDE = 241,
CANT_BE_REMOVED_FROM_GAME = 242,
CANT_BE_READIED = 243,
CANT_BE_EXHAUSTED = 244,
CANT_BE_ATTACKED = 245,
CANT_BE_TARGETED = 246,
CANT_BE_DESTROYED = 247,
CANT_BE_SUMMONING_SICK = 253,
FROZEN = 260,
JUST_PLAYED = 261,
LINKEDCARD = 262,
ZONE_POSITION = 263,
CANT_BE_FROZEN = 264,
COMBO_ACTIVE = 266,
CARD_TARGET = 267,
NUM_CARDS_PLAYED_THIS_TURN = 269,
CANT_BE_TARGETED_BY_OPPONENTS = 270,
NUM_TURNS_IN_PLAY = 271,
NUM_TURNS_LEFT = 272,
OUTGOING_DAMAGE_CAP = 273,
OUTGOING_DAMAGE_ADJUSTMENT = 274,
OUTGOING_DAMAGE_MULTIPLIER = 275,
OUTGOING_HEALING_CAP = 276,
OUTGOING_HEALING_ADJUSTMENT = 277,
OUTGOING_HEALING_MULTIPLIER = 278,
INCOMING_ABILITY_DAMAGE_ADJUSTMENT = 279,
INCOMING_COMBAT_DAMAGE_ADJUSTMENT = 280,
OUTGOING_ABILITY_DAMAGE_ADJUSTMENT = 281,
OUTGOING_COMBAT_DAMAGE_ADJUSTMENT = 282,
OUTGOING_ABILITY_DAMAGE_MULTIPLIER = 283,
OUTGOING_ABILITY_DAMAGE_CAP = 284,
INCOMING_ABILITY_DAMAGE_MULTIPLIER = 285,
INCOMING_ABILITY_DAMAGE_CAP = 286,
OUTGOING_COMBAT_DAMAGE_MULTIPLIER = 287,
OUTGOING_COMBAT_DAMAGE_CAP = 288,
INCOMING_COMBAT_DAMAGE_MULTIPLIER = 289,
INCOMING_COMBAT_DAMAGE_CAP = 290,
CURRENT_SPELLPOWER = 291,
ARMOR = 292,
MORPH = 293,
IS_MORPHED = 294,
TEMP_RESOURCES = 295,
OVERLOAD_OWED = 296,
NUM_ATTACKS_THIS_TURN = 297,
NEXT_ALLY_BUFF = 302,
MAGNET = 303,
FIRST_CARD_PLAYED_THIS_TURN = 304,
MULLIGAN_STATE = 305,
TAUNT_READY = 306,
STEALTH_READY = 307,
CHARGE_READY = 308,
CANT_BE_TARGETED_BY_ABILITIES = 311,
SHOULDEXITCOMBAT = 312,
CREATOR = 313,
CANT_BE_DISPELLED = 314,
PARENT_CARD = 316,
NUM_MINIONS_PLAYED_THIS_TURN = 317,
PREDAMAGE = 318,
TARGETING_ARROW_TEXT = 325,
ENCHANTMENT_BIRTH_VISUAL = 330,
ENCHANTMENT_IDLE_VISUAL = 331,
CANT_BE_TARGETED_BY_HERO_POWERS = 332,
HEALTH_MINIMUM = 337,
TAG_ONE_TURN_EFFECT = 338,
SILENCE = 339,
COUNTER = 340,
ARTISTNAME = 342,
HAND_REVEALED = 348,
ADJACENT_BUFF = 350,
FLAVORTEXT = 351,
FORCED_PLAY = 352,
LOW_HEALTH_THRESHOLD = 353,
SPELLPOWER_DOUBLE = 356,
HEALING_DOUBLE = 357,
NUM_OPTIONS_PLAYED_THIS_TURN = 358,
TO_BE_DESTROYED = 360,
AURA = 362,
POISONOUS = 363,
HOW_TO_EARN = 364,
HOW_TO_EARN_GOLDEN = 365,
HERO_POWER_DOUBLE = 366,
AI_MUST_PLAY = 367,
NUM_MINIONS_PLAYER_KILLED_THIS_TURN = 368,
NUM_MINIONS_KILLED_THIS_TURN = 369,
AFFECTED_BY_SPELL_POWER = 370,
EXTRA_DEATHRATTLES = 371,
START_WITH_1_HEALTH = 372,
IMMUNE_WHILE_ATTACKING = 373,
MULTIPLY_HERO_DAMAGE = 374,
MULTIPLY_BUFF_VALUE = 375,
CUSTOM_KEYWORD_EFFECT = 376,
TOPDECK = 377,
CANT_BE_TARGETED_BY_BATTLECRIES = 379,
SHOWN_HERO_POWER = 380,
DEATHRATTLE_RETURN_ZONE = 382,
STEADY_SHOT_CAN_TARGET = 383,
DISPLAYED_CREATOR = 385,
POWERED_UP = 386,
SPARE_PART = 388,
FORGETFUL = 389,
CAN_SUMMON_MAXPLUSONE_MINION = 390,
OBFUSCATED = 391,
BURNING = 392,
OVERLOAD_LOCKED = 393,
NUM_TIMES_HERO_POWER_USED_THIS_GAME = 394,
CURRENT_HEROPOWER_DAMAGE_BONUS = 395,
HEROPOWER_DAMAGE = 396,
LAST_CARD_PLAYED = 397,
NUM_FRIENDLY_MINIONS_THAT_DIED_THIS_TURN = 398,
NUM_CARDS_DRAWN_THIS_TURN = 399,
AI_ONE_SHOT_KILL = 400,
EVIL_GLOW = 401,
HIDE_COST = 402,
INSPIRE = 403,
RECEIVES_DOUBLE_SPELLDAMAGE_BONUS = 404,
HEROPOWER_ADDITIONAL_ACTIVATIONS = 405,
HEROPOWER_ACTIVATIONS_THIS_TURN = 406,
REVEALED = 410,
NUM_FRIENDLY_MINIONS_THAT_DIED_THIS_GAME = 412,
CANNOT_ATTACK_HEROES = 413,
LOCK_AND_LOAD = 414,
TREASURE = 415,
SHADOWFORM = 416,
NUM_FRIENDLY_MINIONS_THAT_ATTACKED_THIS_TURN = 417,
NUM_RESOURCES_SPENT_THIS_GAME = 418,
CHOOSE_BOTH = 419,
ELECTRIC_CHARGE_LEVEL = 420,
HEAVILY_ARMORED = 421,
DONT_SHOW_IMMUNE = 422,
HISTORY_PROXY_NO_BIG_CARD = 432,
TRANSFORMED_FROM_CARD = 435,
};
#endif
+70
View File
@@ -0,0 +1,70 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MISC_H_
#define MISC_H_
struct gamesetup_s {
u64 board;
u64 maxsecrets;
u64 maxfriendlyminions;
u64 keepalive;
u64 stuckdisconnect;
};
struct handshake_s {
u64 gamehandle;
char *password;
int npassword;
u64 clienthandle;
u64 mission;
char *version;
int nversion;
struct platform_s *platform;
};
struct platform_s {
u64 os;
u64 screen;
int nname;
char *name;
u64 store;
};
struct chooseoption_s {
u64 id;
u64 index;
u64 target;
u64 suboption;
u64 position;
};
void gamesetup_free(struct gamesetup_s *g);
int gamesetup_serialize(void *data, char **dst, const char *maxdst);
void handshake_free(struct handshake_s *h);
void *handshake_deserialize(char **dst, const char *maxdst);
void platform_free(struct platform_s *p);
struct platform_s *platform_deserialize(char **dst, const char *maxdst);
void chooseoption_free(struct chooseoption_s *c);
void *chooseoption_deserialize(char **dst, const char *maxdst);
void chooseoption_dump(struct chooseoption_s *o, u64 local_held_card);
#endif
@@ -0,0 +1,34 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOUSEINFO_H_
#define MOUSEINFO_H_
struct mouseinfo_s {
u64 arroworigin;
u64 heldcard;
u64 overcard;
u64 x;
u64 y;
};
void mouseinfo_free(struct mouseinfo_s *p);
void *mouseinfo_deserialize(char **dst, const char *maxdst);
int mouseinfo_serialize(void *ao, char **dst, const char *maxdst);
int mouseinfo_size(struct mouseinfo_s *p);
#endif
+60
View File
@@ -0,0 +1,60 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPTIONS_H_
#define OPTIONS_H_
struct suboption_target_s {
u64 value;
struct suboption_target_s *next;
};
struct suboption_s {
u64 id;
struct suboption_target_s *target;
struct suboption_s *next;
};
struct option_s {
u64 type;
struct suboption_s *mainoption;
struct suboption_s *suboptions;
struct option_s *next;
};
struct alloptions_s {
u64 id;
struct option_s *options;
};
void alloptions_free(struct alloptions_s *a);
int alloptions_serialize(void *s, char **dst, const char *maxdst);
int alloptions_size(struct alloptions_s *p);
void option_free(struct option_s *p);
int option_serialize(struct option_s *s, char **dst, const char *maxdst);
int option_size(struct option_s *p);
void suboption_free(struct suboption_s *p);
int suboption_serialize(struct suboption_s *s, char **dst, const char *maxdst);
int suboption_size(struct suboption_s *p);
void alloptions_dump(struct alloptions_s *a);
#endif
+56
View File
@@ -0,0 +1,56 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PACKET_H_
#define PACKET_H_
enum packet_e {
P_GETGAMESTATE = 0x01,
P_CHOOSEOPTION = 0x02,
P_CHOOSEENTITIES = 0x03,
P_TURNTIMER = 0x09,
P_ENTITIESCHOSEN = 0x0D,
P_ALLOPTIONS = 0x0E,
P_USERUI = 0x0F,
P_GAMESETUP = 0x10,
P_ENTITYCHOICES = 0x11,
P_POWERHISTORY = 0x13,
P_SPECTATORNOTIFY = 0x18,
P_PING = 0x73,
P_PONG = 0x74,
P_HANDSHAKE = 0xA8,
};
struct packet_s {
int id;
int len;
void *data;
};
struct packet_deserialize_s {
int id;
void *(*deserialize)(char **dst, const char *end);
int (*serialize)(void *p, char **dst, const char *end);
int (*free)(void *p);
};
void packet_free(struct packet_s *p);
struct packet_s *deserialize(char **dst, const char *maxdst);
int serialize(struct packet_s *p, char **dst, const char *maxdst);
struct packet_s *packet_init(enum packet_e id, void *data);
#endif
@@ -0,0 +1,178 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEF_H_
#define DEF_H_
#define error()\
hm_log(LOG_EMERG, lg, "dst: %p end: %p n: %d", *dst, maxdst, n);\
abort();
struct powerhistory_tag_s {
u64 name;
u64 value;
struct powerhistory_tag_s *next;
};
struct powerhistory_hide_s {
u64 entity;
u64 zone;
};
struct powerhistory_tagchange_s {
u64 entity;
u64 tag;
u64 value;
};
struct powerhistory_entity_s {
u64 entity;
char *name;
int nname;
struct powerhistory_tag_s *tag, *tag_tail;
};
struct powerhistory_powerstart_s {
u64 type;
u64 index;
u64 source;
u64 target;
int ncard_id;
char *card_id;
};
struct powerhistory_powerend_s {
int i;
};
struct powerhistory_game_entity_s {
u64 id;
struct powerhistory_tag_s *tag, *tag_tail;
};
struct powerhistory_s {
struct powerhistory_data_s *data, *data_tail;
};
struct powerhistory_info_s {
u64 id;
struct powerhistory_info_s *next;
};
struct powerhistory_meta_s {
u64 type;
u64 data;
struct powerhistory_info_s *info, *info_tail;
};
struct powerhistory_player_s {
u64 id;
u64 bnet_hi;
u64 bnet_lo;
u64 cardback;
struct powerhistory_game_entity_s *entity;
struct powerhistory_player_s *next;
};
struct powerhistory_creategame_s {
struct powerhistory_game_entity_s *game_entity;
struct powerhistory_player_s *player, *player_tail;
};
struct powerhistory_data_s {
struct powerhistory_entity_s *full;
struct powerhistory_entity_s *show;
struct powerhistory_hide_s *hide;
struct powerhistory_tagchange_s *tagchange;
struct powerhistory_creategame_s *creategame;
struct powerhistory_powerstart_s *powerstart;
struct powerhistory_powerend_s *powerend;
struct powerhistory_entity_s *change_entity;
struct powerhistory_meta_s *meta;
struct powerhistory_data_s *next, *tail;
};
void powerhistory_free(struct powerhistory_s *p);
void *powerhistory_deserialize(char **dst, const char *maxdst);
int powerhistory_serialize(void *data, char **dst, const char *maxdst);
int powerhistory_size(struct powerhistory_s *ph);
struct powerhistory_data_s *powerhistory_data_deserialize(char **dst, const char *maxdst);
int powerhistorydata_serialize(struct powerhistory_data_s *ph, char **dst, const char *maxdst);
int powerhistorydata_size(struct powerhistory_data_s *ph);
void powerhistory_data_free(struct powerhistory_data_s *d);
struct powerhistory_meta_s *meta_deserialize(char **dst, const char *maxdst);
int meta_serialize(struct powerhistory_meta_s *ph, char **dst, const char *maxdst);
int meta_size(struct powerhistory_meta_s *ph);
void meta_free(struct powerhistory_meta_s *t);
struct powerhistory_powerend_s *powerend_deserialize(char **dst, const char *maxdst);
int powerend_serialize(struct powerhistory_powerend_s *ph, char **dst, const char *maxdst);
int powerend_size(struct powerhistory_powerend_s *ph);
void powerend_free(struct powerhistory_powerend_s *p);
struct powerhistory_powerstart_s *powerstart_deserialize(char **dst, const char *maxdst);
int powerstart_serialize(struct powerhistory_powerstart_s *ph, char **dst, const char *maxdst);
int powerstart_size(struct powerhistory_powerstart_s *ph);
void powerstart_free(struct powerhistory_powerstart_s *p);
struct powerhistory_creategame_s *creategame_deserialize(char **dst, const char *maxdst);
int creategame_serialize(struct powerhistory_creategame_s *ph, char **dst, const char *maxdst);
int creategame_size(struct powerhistory_creategame_s *ph);
void creategame_free(struct powerhistory_creategame_s *c);
struct powerhistory_tagchange_s *tagchange_deserialize(char **dst, const char *maxdst);
int tagchange_serialize(struct powerhistory_tagchange_s *ph, char **dst, const char *maxdst);
int tagchange_size(struct powerhistory_tagchange_s *ph);
void tagchange_free(struct powerhistory_tagchange_s *t);
struct powerhistory_hide_s *hide_deserialize(char **dst, const char *maxdst);
int hide_serialize(struct powerhistory_hide_s *ph, char **dst, const char *maxdst);
int hide_size(struct powerhistory_hide_s *ph);
void hide_free(struct powerhistory_hide_s *t);
struct powerhistory_game_entity_s *game_entity_deserialize(char **dst, const char *maxdst);
int game_entity_serialize(struct powerhistory_game_entity_s *ph, char **dst, const char *maxdst);
int game_entity_size(struct powerhistory_game_entity_s *ph);
void game_entity_free(struct powerhistory_game_entity_s *g);
struct powerhistory_entity_s *entity_deserialize(char **dst, const char *maxdst);
int entity_serialize(struct powerhistory_entity_s *ph, char **dst, const char *maxdst);
int entity_size(struct powerhistory_entity_s *ph);
void entity_free(struct powerhistory_entity_s *e);
struct powerhistory_tag_s *tag_deserialize(char **dst, const char *maxdst);
int tag_serialize(struct powerhistory_tag_s *ph, char **dst, const char *maxdst);
int tag_size(struct powerhistory_tag_s *ph);
void tag_free(struct powerhistory_tag_s *t);
void player_free(struct powerhistory_player_s *p);
struct powerhistory_player_s *player_deserialize(char **dst, const char *maxdst);
int player_serialize(struct powerhistory_player_s *ph, char **dst, const char *maxdst);
int player_size(struct powerhistory_player_s *ph);
int bnet_size(struct powerhistory_player_s *ph);
void powerhistory_dump(struct powerhistory_s *p);
#endif
+72
View File
@@ -0,0 +1,72 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROTO_H_
#define PROTO_H_
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <memory.h>
#include <malloc.h>
#include <sys/time.h>
#include <time.h>
#include <ev.h>
#include <hmbase.h>
typedef unsigned long long u64;
int sizeofu64(u64 v);
int sizeofu32(int v);
int stream_write(const char **dst, const char *end, const void *src, const int nsrc);
int write_byte(char **dst, const char *end, const char src);
int write_bytes(char **dst, const char *end, const char *src, const int nsrc);
void write_uint(char **dst, const char *end, int src);
void write_uint64(char **dst, const char *end, u64 src);
int write_mem_int(char **dst, const char *end, const int src);
char read_byte(char **dst, const char *end);
int read_uint(char **dst, const char *end);
u64 read_uint64(char **dst, const char *end);
int read_mem_int(char **dst, const char *end);
char *read_bytes(char **dst, const char *end, int *ndst);
int skip(char **dst, const char *end, const int jump);
#include <ent_gen.h>
#include <flag_def.h>
#include <flags.h>
#include <zone.h>
#include <misc.h>
#include <powerhistory.h>
#include <packet.h>
#include <gametag.h>
#include <ent.h>
#include <entitychoices.h>
#include <chooseentities.h>
#include <options.h>
#include <mouseinfo.h>
#include <userui.h>
#include <turntimer.h>
extern struct hm_log_s *lg;
#endif
@@ -0,0 +1,31 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TURNTIMER_H_
#define TURNTIMER_H_
struct turntimer_s {
u64 seconds;
u64 turn;
char show;
};
void turntimer_free(struct turntimer_s *t);
int turntimer_serialize(void *ao, char **dst, const char *maxdst);
void turntimer_dump(struct turntimer_s *t);
#endif
+33
View File
@@ -0,0 +1,33 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERUI_H_
#define USERUI_H_
struct userui_s {
struct mouseinfo_s *mouseinfo;
u64 emote;
u64 player_id;
};
void userui_free(struct userui_s *u);
int userui_serialize(void *ao, char **dst, const char *maxdst);
void *userui_deserialize(char **dst, const char *maxdst);
int userui_size(struct userui_s *p);
void userui_dump(struct userui_s *u);
#endif
+33
View File
@@ -0,0 +1,33 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ZONE_H_
#define ZONE_H_
enum zone_e {
ZONE_INVALID = 0,
ZONE_PLAY = 1,
ZONE_DECK = 2,
ZONE_HAND = 3,
ZONE_GRAVEYARD = 4,
ZONE_REMOVEDFROMGAME = 5,
ZONE_SETASIDE = 6,
ZONE_SECRET = 7,
ZONE_DISCARD = -2,
};
#endif
+538
View File
@@ -0,0 +1,538 @@
/*
hm_gameserver - hearthmod gameserver
Copyright (C) 2016 Filip Pancik
This program 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 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SECTIONS_H_
#define SECTIONS_H_
#include <section_buff.h>
#include <section_battlecry.h>
#include <section_defender.h>
#include <section_spell.h>
#include <section_spell_aoe.h>
#include <section_attack.h>
#include <section_attack_effect.h>
#include <section_weapon.h>
#include <section_endturn.h>
#include <section_onboard.h>
#include <section_destroyed.h>
#include <section_weapon_destroyed.h>
#include <section_idle.h>
#include <section_weapon_attack.h>
#include <section_attachment_attack.h>
#include <section_attack_effect_attachment.h>
// built-in variables
#define HSL_attacker (attacker)
#define HSL_defender (defender)
#define HSL_defenders (defenders)
#define HSL_player (p)
#define HSL_opponent ((struct hs_holder_s *)(p->opponent.client->data))
#define HSL_deck_player (p->deck_copy)
#define HSL_deck_opponent (p->opponent.deck_copy)
#define HSL_target (opt->target)
#define HSL_ally_hero (p->deck_copy->hero)
#define HSL_enemy_hero (p->opponent.deck_copy->hero)
#define HSL_weapon_player (p->deck_copy->heroweapon)
#define HSL_weapon_opponent (p->opponent.deck_copy->heroweapon)
#define HSL_deck_defender (defender->parent)
#define HSL_fake_defender (__fake_defender)
#define HSL_fake_attacker (__fake_attacker)
#define HSL_fake_weapon (__fake_weapon)
#define HSL_fake_deck (__fake_deck)
#define HSL_fake_levelup (&__fake_levelup)
#define HSL_no_attacker (-1)
#define HSL_heroes_included 1
#define HSL_heroes_excluded 0
#define HSL_magic_immunity_included 1
#define HSL_magic_immunity_excluded 0
// generic macros
#define def(m_type, m_dst) struct m_type *m_dst = NULL;
#define is_spell(m_dst) (flag(&m_dst->state, CARD_SPELL, FLAG_ISSET))
#define cmp_cardname(m_card, m_src) (strcmp(m_card->entity->name, m_src) == 0)
#define hsl_set_windfury(m_dst)\
flag(&m_dst->state, CARD_WINDFURY, FLAG_SET)
#define hsl_set_taunt(m_dst)\
flag(&m_dst->state, CARD_TAUNT, FLAG_SET);
#define hsl_refresh_mana(m_deck, m_amount)\
deck->mana_used = (m_amount > deck->mana_used) ? 0 : deck->mana_used - m_amount ;
#define turn_plays(m_card) (m_card->turn_plays)
/**
* @brief Foreach
*
* @param m_alias iterator
* @param m_src source
*/
#define foreach(m_alias, m_src)\
for(m_alias = m_src; m_alias != NULL; m_alias = m_alias->next)
/**
* @brief Find out if controller is current player
*
* @param m_card played card
*/
#define is_controller_player(m_card)\
(p->id == m_card->parent->deck_copy->controller)
// hsl_* macros
// only works on friendly deck
#define hsl_set_magic_immunity(m_dst)\
force_expire(p, HSL_deck_player, m_dst);\
mechanics_expire(p->game->turn + 2, m_dst, EXPIRE_MAGIC_IMMUNITY, 1, NULL);\
flag(&m_dst->state, CARD_DIVINE_SHIELD, FLAG_SET);
#define hsl_set_fullhealth(m_dst)\
m_dst->health = m_dst->total_health;\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);
#define hsl_swap_health(m_dst, m_src)\
int hp = m_dst->health;\
m_dst->health = m_dst->total_health = m_src->health - m_src->buff_health;\
m_src->health = m_src->total_health = hp + m_src->buff_health;\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);\
flag(&m_src->state, MECHANICS_HEALTH, FLAG_SET);
#define hsl_set_health(m_dst, m_change)\
m_dst->health = m_dst->total_health = (m_change + m_dst->buff_health);\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);
#define hsl_decrease_health(m_dst, m_change)\
m_dst->buff_health -= m_change;\
m_dst->total_health -= m_change;\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);\
if(m_dst->health > m_dst->total_health) {\
m_dst->health = m_dst->total_health;\
}
#define hsl_increase_health(m_dst, m_change)\
m_dst->buff_health += m_change;\
m_dst->health += m_change;\
m_dst->total_health += m_change;\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);
#define hsl_replenish_health(m_dst, m_change)\
if(m_dst->total_health >= (m_dst->health + m_change)) {\
m_dst->health += m_change;\
flag(&m_dst->state, MECHANICS_HEALTH, FLAG_SET);\
}
#define hsl_change_armor(m_dst, m_change)\
m_dst->armor += m_change;\
flag(&m_dst->state, MECHANICS_ARMOR, FLAG_SET);
#define hsl_change_attack(m_dst, m_change)\
m_dst->attack += m_change;\
flag(&m_dst->state, MECHANICS_ATTACK, FLAG_SET);
#define hsl_cards_by_name(m_deck, m_name) (cards_by_name(HSL_player, m_deck, m_name, CARD_BOARD))
#define hsl_board_count_by_name(m_deck, m_name) (board_count_by_name(m_deck, m_name))
#define hsl_board_minions_count(m_deck, m_attacker) cards_get_board_count(m_deck, NULL, 0, m_attacker->id)
#define hsl_add_single_attachment(m_player, m_deck, m_dst, m_src) add_single_attachment(m_player, m_deck, m_dst, m_src)
#define hsl_remove_attachment(m_deck, m_opponent, m_card, m_name) (card_remove_attachment(m_deck, m_opponent, m_card, m_name))
#define level(m_dst) (m_dst->boss.level)
#define is_destroyed(m_dst) (flag(&m_dst->state, CARD_DESTROYED, FLAG_ISSET))
#define is_boss(m_dst) (flag(&m_dst->state, CARD_BOSS, FLAG_ISSET))
#define hsl_apply_attachment(m_player, m_deck, m_dst, m_src) (card_apply_attachment(m_player, m_deck, m_dst, m_src))
#define hsl_cards_get_hand_random(m_deck) (cards_get_hand_random(m_deck))
#define hsl_cards_get_hand(m_deck) (cards_get_hand(m_deck))
#define hsl_receive_damage(m_dst, m_dmg)\
if(m_dst) { m_dst->receive.damage = m_dmg; }
#define hsl_receive_heal(m_dst, m_heal)\
if(m_dst) { m_dst->receive.heal = m_heal; }
#define hsl_freeze(m_src, m_dst)\
hm_log(LOG_DEBUG, lg, "Attacker [%s](%d) froze [%s](%d)", m_src->entity->desc, m_src->id, m_dst->entity->desc, m_dst->id);\
mechanics_expire(p->game->turn + 3, m_dst, EXPIRE_FROZEN, 1, NULL);\
flag(&m_dst->state, CARD_FROZEN, FLAG_SET);
#define hsl_add_defender(m_src, m_holder)\
struct card_list_s *m_holder;\
LIST_ADD(defenders, m_holder, m_src)
#define hsl_return_to_hand(m_card)\
flag(&m_card->state, CARD_BOARD, FLAG_UNSET);\
flag(&m_card->state, CARD_HAND, FLAG_SET);\
flag(&m_card->state, CARD_EXHAUSTED, FLAG_UNSET);\
m_card->health = m_card->total_health = m_card->default_health;\
flag(&m_card->state, MECHANICS_HEALTH, FLAG_SET);\
m_card->attack = m_card->default_attack;\
flag(&m_card->state, MECHANICS_ATTACK, FLAG_SET);\
card_remove_attachment(hsl_deck(m_card), NULL, m_card, NULL);\
card_destroy(m_card, hsl_deck(m_card), 1);\
/* order is importatnt here, new zone position must come after card is destroyed */\
if(m_card->controller == HSL_deck_player->controller) {\
m_card->zone_position = ++(HSL_deck_player->handposition);\
} else {\
m_card->zone_position = ++(HSL_deck_opponent->handposition);\
}\
#define hsl_cards_get_hand(m_deck) (cards_get_hand(m_deck))
#define hsl_add_new_card_hand(m_deck, m_card, m_holder)\
struct card_s *m_holder = add_new_card(m_deck->parent->game, m_deck, -1, m_card, -1);\
flag(&m_holder->state, CARD_HAND, FLAG_SET);\
m_holder->zone_position = ++(m_deck->handposition);
#define hsl_destroy(m_deck, m_dst)\
{\
struct card_s *__fake_defender = m_dst;\
__SECTION_DESTROYED\
}\
flag(&m_dst->state, CARD_DESTROYED, FLAG_SET);\
cards_board_destroyed_reorder(m_deck, m_dst->zone_position);
#define hsl_destroy_inhand(m_dst) card_discard_by_name(HSL_player, HSL_fake_defender, m_dst)
#define hsl_set_weapon_durability(m_dst, m_value)\
m_dst->durability += m_value;\
flag(&m_dst->state, MECHANICS_DURABILITY, FLAG_SET);
#define hsl_weapon_durability(m_dst) m_dst->durability
#define hsl_destroy_weapon(m_attacker, m_deck)\
if(m_deck->heroweapon) {\
/*struct card_list_s *itm;*/\
__SECTION_WEAPON_DESTROYED;\
flag(&m_deck->heroweapon->state, CARD_DESTROYED, FLAG_SET);\
flag(&m_deck->heroweapon->state, CARD_BOARD, FLAG_UNSET);\
flag(&m_deck->heroweapon->state, CARD_HEROWEAPON, FLAG_UNSET);\
flag(&m_deck->heroweapon->state, CARD_EXHAUSTED, FLAG_UNSET);\
\
/*LIST_ADD(m_attacker->target.card, itm, m_holder->deck_copy->heroweapon);*/\
\
flag(&m_deck->heroweapon->state, MECHANICS_DESTROY_WEAPON, FLAG_SET);\
m_deck->heroweapon = NULL;\
}
#define is_weapon(m_deck, m_src) (m_deck && m_deck->heroweapon && strcmp(m_deck->heroweapon->entity->name, m_src) == 0)
#define hsl_change_cost(m_card, m_change)\
(m_card->cost = (m_card->default_cost - m_change >= 0) ? (m_card->default_cost - m_change) : 0);\
flag(&(m_card->state), MECHANICS_COST, FLAG_SET);
#define hsl_card_spell_by_name(m_player, m_deck, m_name) (card_by_name(m_player, m_deck, m_name, CARD_SPELL))
#define hsl_card_board_by_name(m_player, m_deck, m_name) (card_by_name(m_player, m_deck, m_name, CARD_BOARD))
#define hsl_card_hand_by_name(m_player, m_deck, m_name) (card_by_name(m_player, m_deck, m_name, CARD_HAND))
#define hsl_count_attachments(m_deck, m_opponent, m_card, m_name) (card_count_attachment(m_deck, m_opponent, m_card, m_name))
#define hsl_discard_random_hand(m_deck, m_amount, m_holder)\
int m_holder;\
for(m_holder = 0; m_holder < m_amount; m_holder++) {\
struct card_s *m_card = cards_get_hand_random(m_deck);\
if(m_card) {\
flag(&m_card->state, CARD_DISCARD, FLAG_SET);\
flag(&m_card->state, CARD_HAND, FLAG_UNSET);\
cards_reorder_hand_owner(m_deck, m_card->id);\
}\
}
#define hsl_discard_hand(m_deck, m_all)\
struct card_list_s *m_holder;\
for(m_holder = m_all; m_holder != NULL; m_holder = m_holder->next) {\
flag(&m_holder->card->state, CARD_DISCARD, FLAG_SET);\
cards_reorder_hand_owner(m_deck, m_holder->card->id);\
}
#define card(m_list) (m_list->card)
#define hsl_card(m_target)\
card_get(HSL_deck_player, HSL_deck_opponent, m_target)
#define hsl_deck(m_card) ((m_card->controller == HSL_deck_player->controller) ? HSL_deck_player : HSL_deck_opponent)
#define default_health(m_card) (m_card->default_health)
#define default_attack(m_card) (m_card->default_attack)
#define hsl_board_all_cards(m_attacker, m_hero) cards_get_board(p->deck_copy, p->opponent.deck_copy, m_hero, m_attacker->id, HSL_magic_immunity_included, 1)
#define hsl_board_all_cards_no_boss(m_attacker, m_hero) (cards_get_board(p->deck_copy, p->opponent.deck_copy, m_hero, m_attacker->id, HSL_magic_immunity_included, 0))
#define hsl_board_friendly_cards(m_deck, m_attacker, m_hero) (cards_get_board(m_deck, NULL, m_hero, m_attacker, HSL_magic_immunity_included, 1))
#define hsl_board_friendly_cards_wattacker(m_hero) cards_get_board(p->deck_copy, NULL, m_hero, -1, HSL_magic_immunity_included, 1);
#define hsl_board_enemy_cards(m_attacker, m_hero, m_mi) cards_get_board(NULL, p->opponent.deck_copy, m_hero, m_attacker->id, m_mi, 1);
#define hsl_board_friendly_no_boss(m_attacker, m_hero, m_mi) cards_get_board(NULL, p->opponent.deck_copy, m_hero, m_attacker->id, m_mi, 0);
#define hsl_board_boss_cards(m_deck) (cards_get_board_boss(m_deck))
#define hsl_attack_aoe(m_dst, m_src, m_fake_levelup) mechanics_attack_aoe(c, opt->position, m_dst, &m_src, m_fake_levelup)
#define hsl_attack(m_dst, m_src, m_fake_levelup) hsl_attack_aoe(m_dst, m_src, m_fake_levelup)
/**
* @brief Summon card for deck
*
* @param m_deck deck to summon to
* @param m_name name of the card
* @param m_card card holder
**/
#define hsl_summon_card(m_deck, m_name, m_card)\
int m_card##pos = cards_board_last(m_deck);\
if(m_card##pos <= MAX_BOARD) {\
struct card_s *m_card = add_new_card(p->game, m_deck, -1, m_name, -1);\
mechanics_put_card_onboard(c, m_card##pos, m_card, 1, NULL, NULL, m_deck);\
}
/**
* @brief Count number of cards in list of cards
*
* @param m_cards list of cards
**/
#define hsl_count_cards(m_cards) (cards_count(m_cards))
/**
* @brief Get random card from list of cards
*
* @param m_cards list of cards
**/
#define hsl_random_card(m_cards) (card_random(m_cards))
/**
* @brief Draw number of cards from player's deck
*
* @param m_player deck owner
* @param m_deck deck to draw from
* @param m_card card's holder
* @param m_amount number of cards to draw
**/
#define hsl_draw_cards(m_player, m_deck, m_card, m_amount)\
int m_card##idx;\
struct card_s *m_card;\
for(m_card##idx = 0; m_card##idx < m_amount; m_card##idx++) {\
m_card = draw_random_card(m_deck, m_player->entity_id, 0);\
if(m_card) {\
flag(&m_card->state, CARD_HAND, FLAG_SET);\
struct card_list_s *m_card##itm;\
LIST_ADD(defenders, m_card##itm, m_card);\
}\
}
/**
* @brief Link card to another card's targets
*
* @param m_dst destination card
* @param m_src source card
**/
#define hsl_link_target(m_dst, m_src)\
LIST_ADD_LINK(m_dst->target.card, m_src)
/**
* @brief Add target to defenders
*
* @param m_src source card
* @param m_holder variable placeholder
**/
#define hsl_add_target(m_src, m_holder)\
struct card_list_s *m_holder##item;\
LIST_ADD(defenders, m_holder##item, m_src);\
/**
* @brief Attack as battlecry
*
* @param m_attacker attacking card
* @param m_defender defending card
* @param m_damage damage caused
**/
#define hsl_attack_bc(m_attacker, m_defender, m_damage)\
m_defender->receive.damage = m_damage;\
entity_attack(p, m_attacker, m_defender);
/**
* @brief Heal defender by certain amount (alias)
**/
#define hsl_heal_bc(m_attacker, m_defender, m_damage)\
hsl_heal(m_attacker, m_defender, m_damage);
/*
m_defender->receive.heal = m_damage;\
#entity_attack(p, m_attacker, m_defender);\
#struct card_list_s *item;\
LIST_ADD(m_attacker->target.card, item, m_defender);
*/
/**
* @brief Heal defender by certain amount
*
* @param m_attacker healer card
* @param m_defender receiver card
* @param m_damage amount of healing
**/
#define hsl_heal(m_attacker, m_defender, m_damage)\
m_defender->receive.heal = m_damage;\
entity_attack(p, m_attacker, m_defender);\
struct card_list_s *item;\
LIST_ADD(m_attacker->target.card, item, m_defender);
/**
* @brief Mark target as corrupted
*
* Corrupted target is destroyed after m_turn turns
*
* @param m_turn number of turns from current turn when card is destroyed
* @param m_defender destination card
*/
#define hsl_buff_corrupt_expire(m_turn, m_defender)\
flag(&(m_defender->state), CARD_CORRUPTED, FLAG_SET);\
mechanics_expire(p->game->turn + m_turn, m_defender, EXPIRE_DESTROY, 1, NULL)
/**
* @brief Change attack for m_turn turns
*
* @param m_turn expiration turn
* @param m_defender destination card
* @param m_attack value to change
*/
#define hsl_buff_attack_expire(m_turn, m_defender, m_attack)\
m_defender->attack += m_attack;\
flag(&(m_defender->state), MECHANICS_ATTACK, FLAG_SET);\
mechanics_expire(p->game->turn + m_turn, m_defender, EXPIRE_ATTACK, -(m_attack), NULL);
/**
* @brief Change health of card
*
* @param m_card destination card
* @param m_health health value
*/
#define hsl_add_attachment(m_player, m_attacker, m_defender, m_turn)\
add_single_attachment(m_player, hsl_deck(m_defender), m_attacker, m_defender);\
mechanics_expire(p->game->turn + m_turn, m_defender, EXPIRE_ATTACHMENT, 0, m_attacker->attachment);
/**
* @brief Change health of card
*
* @param m_card destination card
* @param m_health health value
*/
#define buff_health(m_card, m_health)\
defenders->card->health = m_health;\
flag(&(m_card->state), MECHANICS_HEALTH, FLAG_SET);
/**
* @brief Set divine shield to card
*
* @param m_card destination card
*/
#define hsl_divine_shield(m_card)\
flag(&(m_card->state), CARD_DIVINE_SHIELD, FLAG_SET);
/**
* @brief Set flag to card
*
* @param m_card destination card
* @param m_flag flag to set
*/
#define setflag(m_card, m_flag)\
flag(&(m_card->state), m_flag, FLAG_SET);
/**
* @brief Unset flag from card
*
* @param m_card destination card
* @param m_flag flag to unset
*/
#define unsetflag(m_card, m_flag)\
flag(&(m_card->state), m_flag, FLAG_UNSET);
/**
* @brief Unset windfury flag from card
*
* @param m_card destination card
*/
#define hsl_unset_windfury(m_card) (flag(&(m_card->state), CARD_WINDFURY, FLAG_UNSET))
/**
* @brief Set exhausted flag to card
*
* @param m_card destination card
*/
#define hsl_set_exhausted(m_card) (flag(&(m_card->state), CARD_EXHAUSTED, FLAG_SET))
/**
* @brief Unset exhausted flag from card
*
* @param m_card destination card
*/
#define hsl_unset_exhausted(m_card) (flag(&(m_card->state), CARD_EXHAUSTED, FLAG_UNSET))
/**
* @brief Transform defender to m_name
*
* Any mechanics like polymorph
*
* @param m_attacker card with ability to transform target
* @param m_defender card being attacked
* @param m_name card code name
*/
#define hsl_transform(m_attacker, m_defender,m_name)\
struct card_s *card;\
card = add_new_card(p->game, p->opponent.deck_copy, -1, m_name, -1);\
card->zone_position = m_defender->zone_position;\
mechanics_put_card_onboard(c, card->zone_position, card, 1, NULL, NULL);\
m_defender->linked = card->id;\
flag(&m_defender->state, CARD_LINKED, FLAG_SET);\
flag(&m_defender->state, CARD_HIDE, FLAG_SET);\
flag(&m_defender->state, CARD_BOARD, FLAG_UNSET);
/**
* @brief Give weapon to player
*
* Called only in '.section onboard'. There is no need to linked destroyed weapon to defenders
*
* @param m_dst hero card
*/
#define hsl_give_weapon(m_dst)\
if(m_dst->heroweapon != NULL) {\
/* destroy weapon first */\
{\
struct card_s *__fake_weapon = m_dst->heroweapon;\
__SECTION_WEAPON_DESTROYED;\
}\
\
m_dst->heroweapon->priority_override = 900;\
flag(&(m_dst->heroweapon->state), CARD_DESTROYED, FLAG_SET);\
flag(&(m_dst->heroweapon->state), CARD_BOARD, FLAG_UNSET);\
flag(&(m_dst->heroweapon->state), CARD_HEROWEAPON, FLAG_UNSET);\
}\
flag(&attacker->state, CARD_BOARD, FLAG_SET);\
flag(&attacker->state, CARD_HEROWEAPON, FLAG_SET);\
m_dst->heroweapon = attacker;
#endif