name: c-evo
title: "C-evo: New Horizons"
version: '1.3.9'
summary: A turn-based empire building strategy game inspired by Civilization II game.
description: |
  With a time scope of several thousand years, it covers aspects of exploration and expansion, industry and agriculture, warfare and diplomacy, science and administration. C-evo follows the spirit of popular turn-based strategy games from the mid 90s, but with more emphasis on powerful AI and careful design of the rules, resulting in a true challenge.
  It is a turn-based strategy game inspired by Civilization 2 game where you can explore the world and build your own empire. New Horizons edition is a continuation of the last released original C-evo 1.2.0 version with many quality improvements:
  * Full Linux platform support
  * Zoomable map by mouse wheel with three tile sizes
  * User defined key mapping
  * Many sample maps included
  * Multiple localizations included
  * High DPI and scaling support
  * Multi monitor support
  * In-game background music
  * And much more
confinement: strict
base: core22
grade: stable
icon: Install/common/c-evo_256x256.png
license: NLPL

environment:
  LD_LIBRARY_PATH: $SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
  PULSE_SERVER: unix:/run/user/1000/pulse/native
  ALWAYS_USE_PULSEAUDIO: '1'

layout:
  /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/sox:
    bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/sox
  /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
    bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
  /usr/share/alsa:
    bind: $SNAP/usr/share/alsa
parts:
  alsa-mixin:
    plugin: dump
    source: https://github.com/diddlesnaps/snapcraft-alsa.git
    source-subdir: snapcraft-assets
    build-packages:
      - libasound2-dev
    stage-packages:
      - libasound2
      - libasound2-plugins
      - yad
    stage:
      # restrict to only audio-related files - you need to ensure
      # that gtk3 is staged for yad to work correctly, to prompt
      # users to connect the alsa plug or proceed with pulseaudio.
      #
      # This helps prevent symbol conflicts in situations where
      # you're using a non-default library, such as those that the
      # gnome-3-34 extension for core18 provides.
      - etc/asound.conf
      - snap/command-chain/alsa-launch
      - usr/bin/yad*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libasound*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libdnsfile*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libFLAC*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjack*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpulse*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libsamplerate*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libspeex*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libvorbis*
      - usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
  c-evo:
    plugin: nil
    source: .
    source-type: local
    after: [lazarus, alsa-mixin]
    stage-packages:
    - sox
    - libsox-fmt-mp3
    - libsox-fmt-pulse
    - libpulse0
    - libsndfile1
    - libportaudio2
    - libxmp4
    - libasound2
    - libasound2-plugins
    # Autodetected dependencies
    - libatk1.0-0
    - libcairo2
    - libdatrie1
    - libfontconfig1
    - libfreetype6
    - libgdk-pixbuf2.0-0
    - libgraphite2-3
    - libgtk2.0-0
    - libharfbuzz0b
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpixman-1-0
    - libpng16-16
    - libthai0
    - libx11-6
    - libxau6
    - libxcb-render0
    - libxcb-shm0
    - libxcb1
    - libxcomposite1
    - libxcursor1
    - libxdamage1
    - libxdmcp6
    - libxext6
    - libxfixes3
    - libxi6
    - libxinerama1
    - libxrandr2
    - libxrender1
    override-build: |
      snapcraftctl build
      lazbuild --build-mode=Release AI/StdAI/StdAI.lpi
      mv AI/StdAI/libstdai.so AI/StdAI/libstdai-$SNAPCRAFT_TARGET_ARCH.so
      lazbuild --build-mode=Release Integrated.lpi
      install -Dm755 c-evo -t $SNAPCRAFT_PART_INSTALL/usr/bin
      install -Dm644 Language.txt -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -Dm644 Language2.txt -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -Dm644 Fonts.txt -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      install -Dm644 Install/common/c-evo.desktop -t $SNAPCRAFT_PART_INSTALL/usr/share/applications
      install -Dm644 Install/common/c-evo.xml -t $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
      install -Dm644 Install/common/c-evo_256x256.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/c-evo.png
      install -Dm644 Install/common/c-evo_256x256.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-cevo.png
      install -Dm644 Install/common/c-evo_256x256.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-cevomap.png
      install -Dm644 AI/StdAI/libstdai-$SNAPCRAFT_TARGET_ARCH.so -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      install -Dm644 AI/StdAI/StdAI.ai.txt -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      install -Dm644 AI/StdAI/StdAI.png -t $SNAPCRAFT_PART_INSTALL/usr/share/c-evo/AI/StdAI
      cp -r Graphics $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Help $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Sounds $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Music $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Tribes $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Localization $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Maps $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r Saved $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
      cp -r "AI Template" $SNAPCRAFT_PART_INSTALL/usr/share/c-evo
    stage:
      - etc
      - usr
      - usr/share/c-evo
      - usr/share/applications/c-evo.desktop
      - usr/share/mime/packages/c-evo.xml
  lazarus:
    plugin: nil
    source: .
    source-type: local
    build-packages:
    - wget
    - libgtk2.0-dev
    override-build: |
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%204.4/lazarus-project_4.4.0-0_amd64.deb
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%204.4/fpc-laz_3.2.2-210709_amd64.deb
      wget -nc https://downloads.sourceforge.net/project/lazarus/Lazarus%20Linux%20amd64%20DEB/Lazarus%204.4/fpc-src_3.2.2-210709_amd64.deb
      apt install ./lazarus-project_4.4.0-0_amd64.deb ./fpc-laz_3.2.2-210709_amd64.deb ./fpc-src_3.2.2-210709_amd64.deb
    stage: [-*]
    prime: [-*]

apps:
  c-evo:
    command-chain: ["snap/command-chain/alsa-launch"]
    command: usr/bin/c-evo
    desktop: usr/share/applications/c-evo.desktop
    plugs:
      - home
      - audio-playback
      - desktop
      - x11
      - alsa
