# Maintainer: Terromur <terromuroz@proton.me>
# Maintainer: Fazri Gading <fazrigading@gmail.com>
pkgname=Hytale-F2P-git
_pkgname=Hytale-F2P
pkgver=0
pkgrel=1
pkgdesc="Hytale-F2P - Unofficial Hytale Launcher for free to play with multiplayer support (rolling git build)"
arch=('x86_64')
url="https://github.com/amiayweb/Hytale-F2P"
license=('custom')
depends=('gtk3' 'nss' 'libxcrypt-compat')
makedepends=('git' 'npm')
provides=('Hytale-F2P' 'hytale-f2p-git')
conflicts=('Hytale-F2P' 'hytale-f2p-git')
source=("git+$url.git" "$_pkgname.desktop")
sha256sums=('SKIP' '46488fada4775d9976d7b7b62f8d1f1f8d9a9a9d8f8aa9af4f2e2153019f6a30')

pkgver() {
  cd "$_pkgname"
  git describe --tags --long | sed 's/^v//;s/-/.r/;s/-/./'
}

build() {
   cd "$_pkgname"
   npm ci
   npm run build:arch
}

package() {
  mkdir -p "$pkgdir/opt/$_pkgname"
  cp -r "$_pkgname/dist/linux-unpacked/"* "$pkgdir/opt/$_pkgname"
  install -Dm644 "$_pkgname.desktop" "$pkgdir/usr/share/applications/$_pkgname.desktop"
  install -Dm644 "$_pkgname/GUI/icon.png" "$pkgdir/usr/share/icons/hicolor/256x256/apps/$_pkgname.png"
}
