# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0

PortGroup               cmake   1.1
PortGroup               github  1.0

github.setup            plibither8 2048.cpp 30597b11aa4b3b68862173b46cf57e0eda20204d
github.tarball_from     archive
version                 2021-10-14
revision                1
categories              games
maintainers             {mails.ucas.ac.cn:chenguokai17 @chenguokai} openmaintainer

platforms               darwin
license                 MIT
description             Fully featured terminal version of the game "2048" \
                        written in C++

long_description        {*}${description}, which is made to run natively on \
                        the GNU/Linux and MacOS platforms.

patchfiles              data_path.diff
checksums               rmd160  78bbae29200907661caeb9d9805d249a46dc6ec9 \
                        sha256  06635b7579512b1b2739ae51b1d3bc76a9f0b30241a041fedf5c917d35fc282e \
                        size    4206277

compiler.cxx_standard   2014

post-destroot {
    move ${destroot}${prefix}/var/2048.cpp/data/scores.txt \
         ${destroot}${prefix}/var/2048.cpp/data/scores.txt.ori
    move ${destroot}${prefix}/var/2048.cpp/data/statistics.txt \
         ${destroot}${prefix}/var/2048.cpp/data/statistics.txt.ori
    move ${destroot}${prefix}/bin/2048 \
         ${destroot}${prefix}/bin/_2048
    system "echo '#!/bin/sh' >> ${destroot}${prefix}/bin/2048"
    system "echo 'cd ${prefix}/bin ' >> ${destroot}${prefix}/bin/2048"
    system "echo './_2048' >> ${destroot}${prefix}/bin/2048"
    system "chmod a+x ${destroot}${prefix}/bin/2048"
}

post-activate {
    if {![file exists ${prefix}/var/2048.cpp/data/scores.txt]} {
        move ${prefix}/var/2048.cpp/data/scores.txt.ori ${prefix}/var/2048.cpp/data/scores.txt
    }
    if {![file exists ${prefix}/var/2048.cpp/data/statistics.txt]} {
        move ${prefix}/var/2048.cpp/data/statistics.txt.ori ${prefix}/var/2048.cpp/data/statistics.txt
    }
}
