public static Siege StartSiege(BigInteger server, City city, User sieger, Card[] cards) { BigInteger height = Blockchain.GetHeight(); Siege siege = RW.CreateSiege(server, city, sieger, cards, height); RW.AddSiegeCityHist(server, city.cityId, siege.id); return(siege); }
public static byte SaveSiege(Siege siege) { byte[] data = Seige2Bytes(siege); return(IO.SetStorageWithKeyPath(data, Const.preServer, Op.BigInt2String(siege.serverID), Const.preCity, Op.BigInt2String(siege.cityID) )); }
public static Siege CreateSiege(BigInteger server, City city, User sieger, Card[] cards, BigInteger startHeight) { Siege siege = new Siege { serverID = server, cityID = city.cityId, ownerEmail = city.ownerID, siegerEmail = sieger.email, startHeight = startHeight, ownerCards = city.ownerCards, siegeCards = cards }; return(siege); }
public static Siege FinishSiege(Siege siege, byte[] randFact) { if (siege.endHeight == 0) { //尚未结算 BigInteger height = Blockchain.GetHeight(); if (height >= siege.startHeight + Const.blocksForSiege) { BigInteger weather = RW.GetWeather(siege.cityID); //[TODO] 添加结算算法 BigInteger scoreOwner = 123; BigInteger scoreSieger = 456; //玩家加分 User owner = RW.FindUser(siege.ownerEmail); User sieger = RW.FindUser(siege.siegerEmail); owner.score += scoreOwner; sieger.score += scoreSieger; RW.SaveUser(owner); RW.SaveUser(sieger); //战役转移 siege.endHeight = height; RW.SaveSiege(siege); return(siege); } else { return(siege); } } else { return(siege); } }
public static byte[] Seige2Bytes(Siege war) { return(new byte[0]); }