{"id":25188312,"url":"https://github.com/hptrk/uni-haskell-assignment","last_synced_at":"2025-04-04T09:42:54.225Z","repository":{"id":276346672,"uuid":"929007516","full_name":"hptrk/UNI-Haskell-Assignment","owner":"hptrk","description":"(UNIVERSITY) A simple battle simulator in Haskell that allows users to simulate battles between different types of units with various stats and abilities. ⚔️","archived":false,"fork":false,"pushed_at":"2025-02-07T16:57:02.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T17:36:16.358Z","etag":null,"topics":["haskell","simulation","university-project"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hptrk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-07T16:32:09.000Z","updated_at":"2025-02-07T17:18:21.000Z","dependencies_parsed_at":"2025-02-07T17:46:30.700Z","dependency_job_id":null,"html_url":"https://github.com/hptrk/UNI-Haskell-Assignment","commit_stats":null,"previous_names":["hptrk/uni-haskell-assignment"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hptrk%2FUNI-Haskell-Assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hptrk%2FUNI-Haskell-Assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hptrk%2FUNI-Haskell-Assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hptrk%2FUNI-Haskell-Assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hptrk","download_url":"https://codeload.github.com/hptrk/UNI-Haskell-Assignment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157083,"owners_count":20893203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","simulation","university-project"],"created_at":"2025-02-09T20:19:32.011Z","updated_at":"2025-04-04T09:42:54.201Z","avatar_url":"https://github.com/hptrk.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Haskell Army Battle Simulation\n\nThis project is a **university assignment** for Haskell, implementing an army battle simulation with different unit types, spells, and combat mechanics.\n\n## 📖 Description\n\nThe program models a battle system where units (mages and entities) fight using spells and direct damage. It includes functionalities for simulating fights, applying spells, healing, and checking battle outcomes.\n\n### ✅ Features:\n- **Entity and Mage System**: Each unit has health and can perform actions.\n- **Battle Mechanics**: Units take damage, cast spells, and fight until one army is eliminated.\n- **Healing System**: Supports single-unit healing and chain healing effects.\n- **Spell Effects**: Different mages have unique spell behaviors.\n- **Army Management**: Supports unit sorting, filtering, and health checking.\n\n## 📜 Implemented Concepts\n\n- **Algebraic Data Types** (`data` for different entities and states)\n- **Pattern Matching** (for different cases in combat logic)\n- **Recursion** (handling repeated battle actions)\n- **Higher-Order Functions** (spells applied dynamically)\n- **Custom Typeclasses** (`Show` and `Eq` instances for custom data types)\n\n## 🛠️ How It Works\n\n### 1. Define Units and Spells  \n- Mages (`Master`) have unique spells.  \n- Entities include `Golem` and `HaskellElemental`.  \n\n### 2. Battle Mechanics  \n- The `fight` function processes battles turn by turn.  \n- Units attack based on predefined rules.  \n- The battle continues until one army is defeated.  \n\n### 3. Additional Features  \n- `haskellBlast`: Targets multiple enemies with area damage.  \n- `multiHeal`: Heals units sequentially.  \n- `chain`: Applies healing and damage alternately.  \n\n## 📌 Example Code Snippets\n\n### Define a mage:\n```haskell\npapi = Master \"Papi\" 126 (\\enemyHP -\u003e if enemyHP \u003c 8 then 0 else if even enemyHP then div (enemyHP * 3) 4 else enemyHP - 3)\n```\n### Check if a unit is alive:\n```haskell\nisUnitAlive :: Unit -\u003e Bool\nisUnitAlive (M (Alive _)) = True\nisUnitAlive (E (Alive _)) = True\nisUnitAlive _ = False\n```\n### Simulate a battle:\n```haskell\nbattle :: Army -\u003e EnemyArmy -\u003e Maybe Army\nbattle x y\n  | countAliveUnits x == 0 \u0026\u0026 countAliveUnits y == 0 = Nothing\n  | countAliveUnits x == 0 = Just y\n  | countAliveUnits y == 0 = Just x\n  | otherwise = battle (formationFix (multiHeal 20 (haskellBlast (fight y x)))) (formationFix(fight x y))\n```\n---\n\n⭐ This was a university project and is not actively maintained.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhptrk%2Funi-haskell-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhptrk%2Funi-haskell-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhptrk%2Funi-haskell-assignment/lists"}