# Changelog

All notable changes to this project will be documented in this file.

The second and third number in the version number are the same as the version 
of the game, and the last number is the patch version of this project.

## [Unreleased]

## [0.4.4.1] - 2024-02-24

### Added
- #92 Implement `query` and `satisfy`, which can use simple query languages to 
  query objects and check if object positions satisfy the query.

### Changed
- #88 In activating actions, when multiple actions are generated by one object, they
  will be done immediately and events will be triggered after all of them has 
  been done.
- #97 @jiezichenku move `EventFrame` related codes and classes to 
  `event_controller.py`.
- #73 Now supports `np.random.RandomState` or `random.Random` as random generator, 
  and use builtin `random` as default. Now `numpy` is an optional dependency.

### Fixed
- #89 Kid Kujirai disappear if opponent support area is full.
- #90 @xqm32 False positive type hint on union types.

## [0.4.4.0] - 2024-02-12

Thanks to new contributors: @xqm32 @jiezichenku!

### Added
- #86 Version 4.4 cards and balance changes are implemented.
  - Characters and their talents:
    - Sayu
    - Thoma
    - Cryo Hypostasis
    - Millennial Pearl Seahorse
  - Equipment
    - Sapwood Blace
    - Veteran's Visage
  - Action Cards
    - Jeht
    - Silver and Melus
    - Machine Assembly Line
    - Sunyata Flower
    - Matsutake Meat Rolls
- #60 #67 #68 #71 #72 @xqm32 Add and improve the toolchain of developing and CI.
- #84 New `CreateRandomObjectAction` is implemented, which is used by Rhodeia, 
  Abyssal Summons, etc.

### Changed
- In `UseCardEventArguments`, instead of using `Any` type for `card`, now `card` is
  removed and `card_cost` and `card_name` is added. This change is because with `Any`
  type, pydantic cannot parse the data from json or dict correctly.
- #24 Avoid deep copy when simulating, which improves the performance.
- #71 #78 @jiezichenku In `class_registry`, new `instance_factory` is implemented.
- #80 Docs of network classes are improved.

### Fixed
- #53 #55 #56 @xqm32 Mass typos in the project, which containing wrong variable names.
- #44 #81 Mamere use wrong card version and will raise error when new cards are added.
- #85 Falls and Fortune only generate status on one side.

## [0.4.3.3] - 2024-01-11

### Changed
- When the room is closed in `HTTPRoomServer`, it will try to save room log
  of current match.
- Objects with version check use `accept_same_or_higher_version` function.
- #38 When making damage, objects may be created, and their event arguments
  will be trigger after whole damage action, including object creation is done.
- Make assertion on wrong id settings in `DescDictType`. With wrong id,
  frontend may have unexpected behavior.
- `HTTPServer` now use long-polling when dealing with get states.

### Fixed
- #39 The Boar Princess cannot be triggered when character is defeated with 
  talents.
- #2 Dunyarzad draw card effect will be trigger when it is covered by the new 
  support.
- #35 Equipment will always trigger earlier than character status.
- Some wrong descriptions.
- With memory compression, reset match to a given index will break the diff
  history.
- Dvalin talent can trigger more than once.
- Xiangling's elemental skill with talent will charge 2 points.
- `read_log` in tools support parsing logs with new format.
- Creating Bountyful Core will remove existing Dendro Core.
- Kazuha with elemental skill will not be attacked when breaking Baizhu's 
  elemental burst shield.
- #40 `match.config.max_round_number` takes no effect.

## [0.4.3.2] - 2024-01-01

Happy New Year 2024! New year comes in coding time!

### Added
- #18 `HTTPRoomServer` is implemented, which can manage multiple `HTTPServer`
  in one machine more easily.

### Changed
- #22 When frontend send response on old requests, instead of raising error, 
  ignore the response.
- `HTTPServer` will always send `DIFF` type match states unless it is the first
  match state.
- #23 `Match` will compress histories by default, which saves memory but
  will be lower to reset match to a given index. You can disable it by setting
  `Match.config.compress_history` to `False`.
- Now `Yuegui` generated by `Yaoyao` will heal and make damage in one action 
  instead of two.
- Now Chinese README is shown by default.

### Fixed
- #14 Build bug in Python 3.11 and Python 3.12.
- #36 When character is defeated or revived, the skill use counters are not
  cleared.
- #20 When card is generated during match or moved between deck and hands,
  the may have wrong usage status, e.g., "I Haven't Lost Yet!", "Ellin", etc.
- Mamere will not trigger when a card is played but failed to use.
- Some typos in description.

## [0.4.3.1] - 2023-12-21

### Added
- HTTP Server will send uuid to frontend, and frontend will send uuid to server
  in response and state request (except state request that start with 0). If
  uuid is not matched, server will return error.
- New data for Version 4.3
  - Added new characters and their talents:
    - Layla
    - Light's Remit
    - Yelan
    - Turn Control
    - Lyney
    - Conclusive Ovation
    - Lynette
    - A Cold Blade Like a Shadow
    - Gorou
    - Rushing Hound: Swift as the Wind
    - Alhaitham
    - Structuration
    - Signora
    - Pain for Pain
    - Eremite Scorching Loremaster
    - Scorpocalypse
    - Thunder Manifestation
    - Grieving Echo
    - Dvalin
    - Rending Vortex
    - Azhdaha
    - Lunar Cycles Unending
  - Added new Action Cards:
    - Lost Prayer to the Sacred Winds
    - Tulaytullah's Remembrance
    - Beacon of the Reed Sea
    - Primordial Jade Winged-Spear
    - Light of Foliar Incision
    - Gilded Dreams
    - Flowing Rings
    - Echoes of an Offering
    - Heart of Khvarena's Brilliance
    - Vourukasha's Glow
    - Weeping Willow of the Lake
    - Opera Epiclese
    - Mamere
    - Seed Dispensary
    - Memento Lens
    - Passing of Judgment
    - The Boar Princess
    - Falls and Fortune
    - Flickering Four-Leaf Sigil
    - Fish and Chips
- `deck_code_data.json` is updated for new cards

### Changed
- Balance changes in Version 4.3
  - Dehya
  - Rhodeia of Loch
  - Fatui Pyro Agent
  - Wind and Freedom
  - Stone and Contracts
  - Joyous Celebration
  - Timaeus
  - Wagner
  - Ocean-Huled Clam
- Default values for CardBase.cost_label is removed. Cards should explicitly
  set cost_label for them.
- `http_log_replay.py` now supports new type of logs, and when error occurs,
  it will give warning and start a HTTP server with successfully replayed 
  match.
- Minor changes in `pytest.ini`.
- `SummonBase` now must contain damage and damege_element_type.
- Tartaglia, Xiao, Wanderer and Cyno will change its cardface when meets their
  conditions.

### Fixed
- Timaeus cannot decrease cost when drew in the round (i.e. Liben, 
  Strategize).
- Cost of Butter Crab is wrong.
- Base talents (not triggering skills) cannot use when character is stunned
  (e.g. Frozen).
- Bug in deck code generation, which will generate invalid codes.
- Wrong log information for DrawCardAction.
- Wrong target of Kaeya's Talent when healing self.

## [0.4.2.4] - 2023-12-13

### Added
- added `http_log_replay.py` to replay logs.

### Fixed
- errors in `main.py`.
- typos in `deck_code_data.json`.
- Yayoi Nantsuki decreases Artifact cost based on Weapon number.
- Timaeus and Wagner is not treated as Companion.
- Aquila Favonia will heal character when it is not active.
- Where is the Unseen Razor will decrease opponent weapon cost.
- Tenacity of the Millelith will generate dice when the character is defeated
  during the attack.

### Changed
- `heal_self` is changed to `attack_self` in `SkillBase`.
- `CharacterDefeatedAction` will also return `RemoveObjectEventArguments`.
- `deck_code_data` structure is changed. Characters will have `character:`
  prefix.
- `HTTPServer` now use GZip.
- Rhodeia's Elemental Skill will give version hint when generating summons.
- `is_corresponding_character_use_damage_skill` from Damage values
  will ignore damages that is caused by elemental reaction.
- Some redundant assertions are removed.
- `command_history` in `HTTPServer.log` is changed, now it will record the
  corresponding frame number and command order in the history.

## [0.4.2.3] - 2023-12-03

### Added
- `get_class_by_base_class` for `ClassRegistry`, which can get all classes 
  that are inherited from the base class.
- Before using a card, card usage will be checked by `UseCardValue`, which can
  mark a card failed to use.
- Added `/deck_code_data` endpoint in HTTPServer, which can get deck code data
  from server, and frontend can generate deck code without asking server.
- Now default_version will be recorded in `Deck`. If not specified, it is 
  `None`.
- Now `/log` in `HTTPServer` will log match_config.
- `AttackAndGenerateStatusSummonBase` is added for summons perform like Dehya's
  Elemental Skill summon, which will generate status at each round, and when it
  is removed, the corresponding status will also be removed.
- `CreateStatusPassiveSkill` is implemented for characters that will generate
  status when they are created. 
- Now costs of cards and skills will be recorded in `desc_registry`, and passed
  to frontend by `/patch` in `HTTPServer`.

### Fixed
- wrong description of Gambler's Earrings with version 3.3.
- Typo of error message in class_registry.
- When deck code contains unknown card number, it will raise error. After 
  fixing this, it will ignore unknown card number.
- RoundEffectSupports, e.g. Paimon, NRE, is not inherited from its 
  corresponding base class (e.g. CompanionBase, ItemBase).
- Wrong cost of Joyous Celebration.
- Characters that has status created at game start, e.g. Raiden Shogun, will 
  not gain the status when revive. Now they will inherit 
  `CreateStatusPassiveSkill` to gain the status and handle revive actions.
- When character is stunned (e.g. Frozen), it can still use skill by equipping
  Skill Talent cards.
- Targtaglia will accidently increase additional damage caused by elemental
  reaction, e.g. Electro-Charged.
- Wrong character order when triggering events. Previously is active character
  then left first; now is active character then next first.
- Can switch to current active character from current active character in 
  `Match`, though no cards or skills can trigger it now.
- #12 When summon triggers other events that will stack self, e.g. Burning
  Flame, if it is currently in max usage, it still keeps max usage after 
  attacking. This is fixed by using `ChangeObjectUsageAction` instead of 
  modifying its usage by itself directly.

# Changed
- Move template files to `templates` folder.
- Define `AllCharacterFoodCard` for foods that will effect all characters.
- Now `CostLabels` contains `EQUIPMENT` and `EVENT` enum, to represent 
  equipment (Weapons, Artifacts, most Talent cards) and event cards (Most
  normal event cards, Arcane-legend cards, and some talents).
- New `FactionType` is added for future characters.
- `ChangeUsageAction` removes `change_type`, it only supports change type of
  `DELTA` now.

## [0.4.2.2] - 2023-11-18

### Added
- #4 #5 #9 Implement class registry, which supports registering class by name 
  and getting class by name. It also supports registering classes after lpsim 
  is initialized.
- #13 Implement desc registry, which saves the descriptions of classes. When a 
  class is registered in the class registry, a valid description is required.
- Implement `/patch` endpoint in HTTPServer, which can be used to get 
  description patches from server.
- #3 Support create `Deck` from deck code, or export `Deck` to deck code.
  Also add related APIs in HTTPServer.

### Changed
- Now `desc` for a class means description hints for the class, e.g. with 
  talent activated, descriptions of some class will change. `desc` is a Literal
  now and default contains empty string. If a class has hints, add more strings
  into it, and modify `desc` when situation matches. When `desc` is set, its
  corresponding descriptions should also be valid. Refer to Sucrose's Large
  Wind Spirit and desc_class for more details.
- #6 Now HTTPServer will send detailed error about deck in `/deck` when deck is 
  invalid.

### Fixed
- #7 Nilou E cannot generate Bountiful Core in the first time.

## [0.4.2.1] - 2023-11-05

### Changed
- Balance changes of 4.2
  - Characters
    - Arataki Itto
    - Rhodeia of Loch
    - Shenhe
    - Yanfei
    - Jean
  - Talents
    - Xingqiu
    - Barbara
    - Mirror Maiden
    - Electro Hypostasis
    - Chongyun
    - Xiangling
    - Yoimiya
    - Candace
    - Razor
    - Beidou
    - Kujou Sara
    - Cyno
    - Sangonomiya Kokomi
    - Amber
    - Jean
    - Yanfei
  - Cards
    - Joyous Celebration
- For SkillTalents, they no longer record the skill object that will trigger;
  instead, it records the name of the skill, and find the skill object when
  it is triggered.
- When performing reroll-dice, instead of saving states in history for each
  reroll, now no states will be saved during reroll, and frontend will get
  latest dice color in the request.

### Fixed
- Bug of Seed of Skandha, which will cause match error when triggered and 
  target is defeated.
- Bug of shield from Baizhu, which will revive character.
- Skills that will add status to target, e.g. elemental burst of Nilou, will
  raise error when target is defeated by the skill.
- Nilou's talent will raise error when summon disappears after attack.
- I Haven't Lost Yet cannot use if it's not in hand when character is defeated.

## [0.4.2.0] - 2023-11-04

### Added
- All characters and cards in 4.2 are implemented.
  - Characters and their talents:
    - Nilou
    - Dori
    - Baizhu
    - The Starry Skies Their Flowers Rain
    - Discretionary Supplement
    - All Things Are of the Earth
  - Equipment
    - Ocean-Hued Clam
    - Shadow of the Sand King
  - Supports
    - Stormterror's Lair
  - Event Cards
    - Lyresong
    - In Every House a Stove
- Implement DeclareRoundEndAttackSummonBase, RoundEndAttackCharacterStatus,
  and replace parent classes of related objects.
- Added new interface for HTTPServer, so client can get current running server
  version.

### Changed
- AttackerSummonBase support healing.
- Remove source_player_idx and target_player_idx from MakeDamageAction, and
  change change_character logic while making damages.

### Fixed
- Typo of Calx's Arts.
- When healing self character, Itto can get Superlative Superstrenth.

## [0.4.1.3] - 2023-10-31

### Added
- Add `Deck.to_str` function.
- Add object trashbin to make objects able to trigger events when they are 
  removed. #2

### Changed
- Melody loop now heal and make elemental application in one action.
- When a card is used, now it will be firstly moved into table.using_hand.
- Riptide and Dunyarzad are now implemented based on new object trashbin.
- Decks in logs of HTTPServer will save deck string instead of dict.

### Fixed
- Dehya summon logic bug. #1
- Keqing can use Lightning Stiletto when she is frozen.

## [0.4.1.2] - 2023-10-24

### Fixed
- Added dictdiff, fastapi and uvicorn into dependencies.

## [0.4.1.1] - 2023-10-24

### Added
- IconType for Summons, Status, and Supports.
- Histories by action level, now important actions will generate a history,
  and frontend can see what happened during two requests.
- Re-create mode is added to Match, in this mode, all randomness is removed,
  which can be used to re-create existing matches.
- Add `Match.last_action` and `Match.action_info` to get information for 
  frontend.
- Skill prediction support is added. When it is player's turn, regardless of 
  the skill is able to use or not (except skill the cannot use at all, e.g. 
  passive skills and prepare skills), the diff of Match after using a skill 
  will be calculated and saved in `Match.skill_prediction`.
- Add submodule `frontend` to match frontend commits with backend commits.
- Add HTTP server to serve match.

### Changed
- Ocean Mimic generation logic of Rhodeia has changed. Both old and new logics
  are valid, but they will generate different Ocean Mimics with the same random
  state, and the number of times that random function called is different. 
- `Match.history_level` is moved into `Match.config`.
- Location Sangonomiya will heal all characters in one action.
- Move repo from zyr17/GITCG to LPSim/backend.

### Fixed
- Icyquill with only one usage will affect multiple times.
- 1 usage Icyquill with Wanderer will cause wrong damage calculation.
- I Haven't Lost Yet will activate even if opponent character is defeated.
- Wrong damage increase with back damage of Eye of Stormy Judgement.
- Typo in element artifact descriptions.
- Chef Mao and Dunyarzad's draw-card effect not trigger with zero-cost cards.

## [0.4.1.0] - 2023-10-01

### Added
- All Characters and Cards of 4.1 are implemented.
  - Characters and their talents:
    - Dehya
    - Wanderer
    - Yaoyao
    - Stalwart and True
    - Gales of Reverie
    - Beneficient
  - Equipment
    - MoonPiercer
    - Crown of Watatsumi
  - Supports
    - Yayoi Nanatsuki
    - Gandharva Ville
  - Event cards
    - Fresh Wind of Freedom (implemented in previous release)
    - Pankration!

### Changed
- Balance changes of 4.1 are implemented.
  - Kamisato Ayato
  - Fatui Cryo Cicin Mage
  - Tartaglia
  - Diona
  - Xingqiu
  - NRE
  - Teyvat Fried Egg
  - Wind and Freedom
  - Dunyarzad
  - Chef Mao
  - Emblem of Severed Fate
  - Blessing of the Divine Relic's Installation
  - Master of Weaponry

### Fixed
- Unconsistency of RandomAgent in tests.
- ChargeAction of some skills are earlier than making damage, which may cause
  damage calculation error with Shimenawa's Reminiscence equipped.
- Tartaglia do not attach Riptide to the target when using elemental burst
  in ranged mode.
- Absolute imports of some characters.

## [0.4.0.0] - 2023-09-30

### Added
- All Characters and Cards until 4.0 are implemented.
- Some of characters and cards that has balance change in 4.1 are updated 
  as 4.1 version.
  - Kamisato Ayato
  - Fatui Cryo Cicin Mage
  - Wind and Freedom
  - Dunyarzad
  - Chef Mao
  - Emblem of Severed Fate
  - Blessing of the Divine Relic's Installation
  - Master of Weaponry
- One new card in 4.1 is implemented.
  - Fresh Wind of Freedom

## [0.1.0] - 2023-09-18

### Added
- Test version to ensure release pipeline is working

[Unreleased]: https://github.com/LPSim/backend/compare/v0.4.4.1...HEAD
[0.4.4.1]: https://github.com/LPSim/backend/releases/tag/v0.4.4.1
[0.4.4.0]: https://github.com/LPSim/backend/releases/tag/v0.4.4.0
[0.4.3.3]: https://github.com/LPSim/backend/releases/tag/v0.4.3.3
[0.4.3.2]: https://github.com/LPSim/backend/releases/tag/v0.4.3.2
[0.4.3.1]: https://github.com/LPSim/backend/releases/tag/v0.4.3.1
[0.4.2.4]: https://github.com/LPSim/backend/releases/tag/v0.4.2.4
[0.4.2.3]: https://github.com/LPSim/backend/releases/tag/v0.4.2.3
[0.4.2.2]: https://github.com/LPSim/backend/releases/tag/v0.4.2.2
[0.4.2.1]: https://github.com/LPSim/backend/releases/tag/v0.4.2.1
[0.4.2.0]: https://github.com/LPSim/backend/releases/tag/v0.4.2.0
[0.4.1.3]: https://github.com/LPSim/backend/releases/tag/v0.4.1.3
[0.4.1.2]: https://github.com/LPSim/backend/releases/tag/v0.4.1.2
[0.4.1.1]: https://github.com/LPSim/backend/releases/tag/v0.4.1.1
[0.4.1.0]: https://github.com/LPSim/backend/releases/tag/v0.4.1.0
[0.4.0.0]: https://github.com/LPSim/backend/releases/tag/v0.4.0.0
[0.1.0]: https://github.com/LPSim/backend/releases/tag/v0.1.0
