Commit f7f028cb authored by nanahira's avatar nanahira

add DeckCode

parent 00071a3b
Pipeline #2633 passed with stages
in 1 minute and 54 seconds
......@@ -18,6 +18,7 @@ namespace WindBot.Game
public Deck Deck { get; private set; }
public Deck DeckForWin { get; private set; }
public Deck DeckForLose { get; private set; }
public string DeckCode { get; private set; }
private GameAI _ai;
......@@ -47,10 +48,15 @@ namespace WindBot.Game
_ai = new GameAI(Game, _duel);
_ai.Executor = DecksManager.Instantiate(_ai, _duel);
string deckName = Game.DeckFile ?? _ai.Executor.Deck;
Deck = Deck.Load(deckName);
DeckForWin = Deck.Load("Win/" + deckName);
DeckForLose = Deck.Load("Lose/" + deckName);
if(Game.DeckCode != null) {
DeckCode = Game.DeckCode;
} else {
DeckCode = null;
string deckName = Game.DeckFile ?? _ai.Executor.Deck;
Deck = Deck.Load(deckName);
DeckForWin = Deck.Load("Win/" + deckName);
DeckForLose = Deck.Load("Lose/" + deckName);
}
_select_hint = 0;
lastDuelResult = 2;
}
......@@ -152,6 +158,15 @@ namespace WindBot.Game
private BinaryWriter buildUpdateDeck(Deck targetDeck) {
BinaryWriter deck = GamePacketFactory.Create(CtosMessage.UpdateDeck);
if(DeckCode != null) {
try {
byte[] deckContent = Convert.FromBase64String(DeckCode);
deck.Write(deckContent);
} catch {
_ai.OnDeckError("base64 decode");
}
return deck;
}
deck.Write(targetDeck.Cards.Count + targetDeck.ExtraCards.Count);
//Logger.WriteLine("Main + Extra: " + targetDeck.Cards.Count + targetDeck.ExtraCards.Count);
deck.Write(targetDeck.SideCards.Count);
......@@ -179,6 +194,9 @@ namespace WindBot.Game
}
private Deck pickDeckOnResult() {
if(DeckCode != null) {
return null;
}
if(lastDuelResult == 0 && DeckForWin != null) {
//Logger.WriteLine("Using deck for win: " + DeckForWin.SideCards[2].Name);
return DeckForWin;
......
......@@ -14,6 +14,7 @@ namespace WindBot.Game
public string Username;
public string Deck;
public string DeckFile;
public string DeckCode;
public string Dialog;
public int Hand;
public bool Debug;
......@@ -31,6 +32,7 @@ namespace WindBot.Game
Username = Info.Name;
Deck = Info.Deck;
DeckFile = Info.DeckFile;
DeckCode = Info.DeckCode;
Dialog = Info.Dialog;
Hand = Info.Hand;
Debug = Info.Debug;
......
......@@ -69,6 +69,7 @@ namespace WindBot
Info.Name = Config.GetString("Name", Info.Name);
Info.Deck = Config.GetString("Deck", Info.Deck);
Info.DeckFile = Config.GetString("DeckFile", Info.DeckFile);
Info.DeckCode = Config.GetString("DeckCode", Info.DeckCode);
Info.Dialog = Config.GetString("Dialog", Info.Dialog);
Info.Host = Config.GetString("Host", Info.Host);
Info.Port = Config.GetInt("Port", Info.Port);
......@@ -108,6 +109,9 @@ namespace WindBot
string deckfile = HttpUtility.ParseQueryString(RawUrl).Get("deckfile");
if (deckfile != null)
Info.DeckFile = deckfile;
string deckcode = HttpUtility.ParseQueryString(RawUrl).Get("deckcode");
if (deckcode != null)
Info.DeckCode = deckcode;
string dialog = HttpUtility.ParseQueryString(RawUrl).Get("dialog");
if (dialog != null)
Info.Dialog = dialog;
......
......@@ -7,6 +7,7 @@ namespace WindBot
public string Name { get; set; }
public string Deck { get; set; }
public string DeckFile { get; set; }
public string DeckCode { get; set; }
public string Dialog { get; set; }
public string Host { get; set; }
public int Port { get; set; }
......@@ -20,6 +21,7 @@ namespace WindBot
Name = "WindBot";
Deck = null;
DeckFile = null;
DeckCode = null;
Dialog = "default";
Host = "127.0.0.1";
Port = 7911;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment