# vim:ft=ansible:
#
# Docs available here:
# https://github.com/JACOBSMILE/tmodloader1.4
#
# If you need to run a command in this container:
#  docker exec tmodloader inject "say Hello World!"
#
- name: set backups tmodloader - generic
  vars:
    backup_dirs:
      - "/data/tmodloader/generic/data/tModLoader/Worlds"
  ansible.builtin.cron:
    user: root
    name: terraria-generic-backup
    state: present
    minute: "*/15"
    job: "tar czvf \"/data/tmodloader/generic/backups/world-$(date +%Y-%m-%d-%H%M).tgz\" {{ backup_dirs | join(' ') }}"
  tags: [ docker, tmodloader, generic, cron, backup, tar ]
- name: assure backups dir tmodloader - generic
  ansible.builtin.file:
    path: /data/tmodloader/generic/backups
    state: directory
    owner: root
    group: root
    mode: "0700"
  tags: [ docker, tmodloader, generic, file, directory, backup ]
- name: docker deploy tmodloader - generic
  vars:
    mods_qol:
      # Better Zoom: Enables zooming out further than 100% for higher-res monitors
      - "2562953970"
      # Smarter Cursor: Cursor be smarter idort
      - "2877850919"
      # Heart Crystal & Life Fruit Glow
      - "2853619836"
      # Ore Excavation (Veinminer)
      - "2565639705"
      # Shared World Map
      - "2815010161"
      # Auto Trash
      - "2565540604"
      # Quality of Terraria (IT HAS INSTA HOIKS LET'S FUCKING GO)
      # Also adds the "Can be shimmered into" and similar text
      - "2797518634"
      # Boss Cursor
      - "2816694149"
      # WMITF (What Mod Is This From (WAILA (WAWLA (WTFAILA))))
      - "2563851005"
      # Multiplayer Boss Fight Stats
      - "2822937879"
      # Census (Shows you all the NPCs and their move-in requirements)
      - "2687866031"
      # Shop Expander (Prevents overloading shops)
      - "2828370879"
    mods_basics:
      # Magic Storage Starter Kit
      - "2906446375"
      # Magic Storage, absoluteAquarian utilities
      - "2563309347"
      - "2908170107"
      # Wing Slot Extra
      - "2597324266"
      # Fishing with Explosives
      - "3238219681"
      # The Shop Market (it's like the Market from that one Minecraft mod)
      - "2572367426"
      # Chat Source
      - "2566083800"
      # Happiness Removal
      - "2563345152"
      # Better Caves
      - "3158254975"
      # Generated Housing (Adds pregenned home)
      - "3141716573"
    mods_calamity:
      # Calamity, Calamity Music, CalValEX
      - "2824688072"
      - "2824688266"
      - "2824688804"
      # Calamity Ranger Expansion
      - "2860270524"
      # Calamity Whips
      - "2839001756"
    mods_clamity:
      # Clamity (sic), Music
      - "3028584450"
      - "3161277410"
    mods_fargos:
      # Luminance, library mod
      - "3222493606"
      # Fargos Mutant Mod. Adds the NPC and infinite items and instas and stuff
      - "2570931073"
      # Fargos Souls, adds... souls
      - "2815540735"
      # Fargos Souls DLC (Calamity compat)
      - "3044249615"
      # Fargos Souls More Cross-Mod (Consolaria, Spirit, Mod of Redemption compat)
      - "3326463997"
    mods_content:
      # Subworld Lib: Required by a few mods (TSA and others)
      - "2785100219"
      # Moomoo's Yoyo Revamp (and Lib)
      - "2977808495"
      - "3069154070"
      # Gensokyo (UN Owen Was Her plays in the distance)
      - "2817254924"
      # Secrets of the Shadows
      - "2843112914"
      # Spirit Mod
      - "2982372319"
    mods: "{{ mods_qol + mods_basics + mods_calamity + mods_clamity + mods_fargos + mods_content }}"
  community.general.docker_container:
    name: tmodloader-generic
    state: started
    image: jacobsmile/tmodloader1.4:latest
    env:
      TMOD_AUTODOWNLOAD: "{{ mods | join(',') }}"
      TMOD_ENABLEDMODS: "{{ mods | join(',') }}"
      TMOD_SHUTDOWN_MESSAGE: "Server is going down NOW!"
      TMOD_MOTD: "Da bois doin da Terraria again lesgo"
      TMOD_PASS: "dicks"
      TMOD_WORLDNAME: "Seaborgium"
      #TMOD_WORLDSEED: "foobar"
      # 0   Normal
      # 1   Expert
      # 2   Master
      # 3   Journey
      TMOD_DIFFICULTY: "1"
      TMOD_PORT: "7777"
    ports:
      - "7777:7777/tcp"
      - "7777:7777/udp"
    volumes:
      - /data/tmodloader/generic/data:/data
  tags: [ docker, tmodloader, generic ]