add function tile, tilelevel

This commit is contained in:
Rudy Masson 2024-02-23 23:05:35 +01:00
parent e853921fcd
commit bae336b31b
1 changed files with 55 additions and 8 deletions

View File

@ -37,15 +37,19 @@ function onInit() {
rpc.register("getCard");
rpc.register("upsertCard");
rpc.register("initCard");
rpc.register("getTile");
rpc.register("upsertTile");
rpc.register("initTile");
rpc.register("getTiletype");
rpc.register("upsertTiletype");
rpc.register("initTiletype");
rpc.register("getTilelevel");
rpc.register("upsertTilelevel");
rpc.register("initTilelevel");
rpc.register("getPartys");
rpc.register("getPartyswait");
@ -117,16 +121,59 @@ async function upsertCard(ctx,card) {
var obj = await store.upsert(ctx, "Card", config);
return obj;
}
function initCard(ctx,card) {
var obj = store.get(ctx, "Card",card._id);
if(obj) card.value=obj.value;
var obj = store.upsert(ctx, "Card", card);
return obj;
}
// Repository Tile
async function getTile(ctx,id) {
var obj = await store.get(ctx, "Tile",id);
if(obj&&!obj.value) obj.value=obj.default;
return obj;
}
async function upsertTile(ctx,card) {
var obj = await store.upsert(ctx, "Tile", config);
return obj;
}
function initTile(ctx,tile) {
var obj = store.get(ctx, "Tile",tile._id);
if(obj) tile.value=obj.value;
var obj = store.upsert(ctx, "Tile", tile);
}
rpc.register("getTile");
rpc.register("upsertTile");
rpc.register("getTiletype");
rpc.register("upsertTiletype");
rpc.register("getTilelevel");
rpc.register("upsertTilelevel");
// Repository TileType
async function getTiletype(ctx,id) {
var obj = await store.get(ctx, "Tiletype",id);
if(obj&&!obj.value) obj.value=obj.default;
return obj;
}
async function upsertTiletype(ctx,card) {
var obj = await store.upsert(ctx, "Tiletype", config);
return obj;
}
function initTiletype(ctx,tiletype) {
var obj = store.get(ctx, "Tiletype",tiletype._id);
if(obj) tiletype.value=obj.value;
var obj = store.upsert(ctx, "Tiletype", tiletype);
}
// Repository Tilelevel
async function getTilelevel(ctx,id) {
var obj = await store.get(ctx, "Tilelevel",id);
if(obj&&!obj.value) obj.value=obj.default;
return obj;
}
async function upsertTilelevel(ctx,card) {
var obj = await store.upsert(ctx, "Tilelevel", config);
return obj;
}
function initTilelevel(ctx,tilelevel) {
var obj = store.get(ctx, "Tilelevel",tilelevel._id);
if(obj) tilelevel.value=obj.value;
var obj = store.upsert(ctx, "Tilelevel", tilelevel);
}
// Repository Party
async function getPartys(ctx) {