UNPKG

cardation

Version:

fundation of card games, card model

27 lines (26 loc) 724 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../model/serialization/utils"); /** * A serialization tool for decks. */ class Persistence { static serialize(coll) { const cards = coll.getDuplicatedCardArray(); let hash = ''; for (const card of cards) { hash += card.getCardId() + ' '; } return hash.trimEnd(); } static parse(hash) { const ids_array = hash.split(' '); const result = []; for (const id of ids_array) { const card = (0, utils_1.parseCardFromId)(id); result.push(card); } return result; } } exports.default = Persistence;