166 lines
3.5 KiB
TypeScript
166 lines
3.5 KiB
TypeScript
/*
|
|
* Verrückte Turing-Maschinen — A turing complete game
|
|
* Copyright (C) 2016-2018 kcf <vidofnir@folksprak.org>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace mod_vtm
|
|
{
|
|
|
|
export namespace mod_model
|
|
{
|
|
|
|
export namespace mod_actuator
|
|
{
|
|
|
|
export namespace mod_rejector
|
|
{
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
const kind : string = "rejector";
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
export type type_rejector =
|
|
{
|
|
}
|
|
;
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function create
|
|
(
|
|
)
|
|
: type_rejector
|
|
{
|
|
return {
|
|
};
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
export function create_extended
|
|
(
|
|
)
|
|
: mod_actuator.type_actuator
|
|
{
|
|
return lib_call.wrap(kind, create());
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function example
|
|
(
|
|
)
|
|
: type_rejector
|
|
{
|
|
return create();
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function rotate
|
|
(
|
|
rejector : type_rejector,
|
|
increment ?: int
|
|
)
|
|
: void
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function use
|
|
(
|
|
rejector : type_rejector,
|
|
token : mod_token.type_token
|
|
)
|
|
: void
|
|
{
|
|
mod_token.reject(token);
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function export_
|
|
(
|
|
rejector : type_rejector
|
|
)
|
|
: any
|
|
{
|
|
return {
|
|
};
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function import_
|
|
(
|
|
raw : any
|
|
)
|
|
: type_rejector
|
|
{
|
|
return (
|
|
create
|
|
(
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
lib_trait.attend<signature_actuator>
|
|
(
|
|
trait_actuator,
|
|
kind,
|
|
{
|
|
"example": () => lib_call.wrap(kind, example()),
|
|
"rotate": (actuator, increment) => rotate(lib_call.unwrap(actuator), increment),
|
|
"use": (actuator, token) => use(lib_call.unwrap(actuator), token),
|
|
"export": (actuator) => ({"kind": kind, "data": export_(actuator.data)}),
|
|
"import": (raw) => lib_call.wrap(kind, import_(raw["data"])),
|
|
}
|
|
)
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|