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 ...@@ -18,6 +18,7 @@ namespace WindBot.Game
public Deck Deck { get; private set; } public Deck Deck { get; private set; }
public Deck DeckForWin { get; private set; } public Deck DeckForWin { get; private set; }
public Deck DeckForLose { get; private set; } public Deck DeckForLose { get; private set; }
public string DeckCode { get; private set; }
private GameAI _ai; private GameAI _ai;
...@@ -47,10 +48,15 @@ namespace WindBot.Game ...@@ -47,10 +48,15 @@ namespace WindBot.Game
_ai = new GameAI(Game, _duel); _ai = new GameAI(Game, _duel);
_ai.Executor = DecksManager.Instantiate(_ai, _duel); _ai.Executor = DecksManager.Instantiate(_ai, _duel);
if(Game.DeckCode != null) {
DeckCode = Game.DeckCode;
} else {
DeckCode = null;
string deckName = Game.DeckFile ?? _ai.Executor.Deck; string deckName = Game.DeckFile ?? _ai.Executor.Deck;
Deck = Deck.Load(deckName); Deck = Deck.Load(deckName);
DeckForWin = Deck.Load("Win/" + deckName); DeckForWin = Deck.Load("Win/" + deckName);
DeckForLose = Deck.Load("Lose/" + deckName); DeckForLose = Deck.Load("Lose/" + deckName);
}
_select_hint = 0; _select_hint = 0;
lastDuelResult = 2; lastDuelResult = 2;
} }
...@@ -152,6 +158,15 @@ namespace WindBot.Game ...@@ -152,6 +158,15 @@ namespace WindBot.Game
private BinaryWriter buildUpdateDeck(Deck targetDeck) { private BinaryWriter buildUpdateDeck(Deck targetDeck) {
BinaryWriter deck = GamePacketFactory.Create(CtosMessage.UpdateDeck); 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); deck.Write(targetDeck.Cards.Count + targetDeck.ExtraCards.Count);
//Logger.WriteLine("Main + Extra: " + targetDeck.Cards.Count + targetDeck.ExtraCards.Count); //Logger.WriteLine("Main + Extra: " + targetDeck.Cards.Count + targetDeck.ExtraCards.Count);
deck.Write(targetDeck.SideCards.Count); deck.Write(targetDeck.SideCards.Count);
...@@ -179,6 +194,9 @@ namespace WindBot.Game ...@@ -179,6 +194,9 @@ namespace WindBot.Game
} }
private Deck pickDeckOnResult() { private Deck pickDeckOnResult() {
if(DeckCode != null) {
return null;
}
if(lastDuelResult == 0 && DeckForWin != null) { if(lastDuelResult == 0 && DeckForWin != null) {
//Logger.WriteLine("Using deck for win: " + DeckForWin.SideCards[2].Name); //Logger.WriteLine("Using deck for win: " + DeckForWin.SideCards[2].Name);
return DeckForWin; return DeckForWin;
......
...@@ -14,6 +14,7 @@ namespace WindBot.Game ...@@ -14,6 +14,7 @@ namespace WindBot.Game
public string Username; public string Username;
public string Deck; public string Deck;
public string DeckFile; public string DeckFile;
public string DeckCode;
public string Dialog; public string Dialog;
public int Hand; public int Hand;
public bool Debug; public bool Debug;
...@@ -31,6 +32,7 @@ namespace WindBot.Game ...@@ -31,6 +32,7 @@ namespace WindBot.Game
Username = Info.Name; Username = Info.Name;
Deck = Info.Deck; Deck = Info.Deck;
DeckFile = Info.DeckFile; DeckFile = Info.DeckFile;
DeckCode = Info.DeckCode;
Dialog = Info.Dialog; Dialog = Info.Dialog;
Hand = Info.Hand; Hand = Info.Hand;
Debug = Info.Debug; Debug = Info.Debug;
......
...@@ -69,6 +69,7 @@ namespace WindBot ...@@ -69,6 +69,7 @@ namespace WindBot
Info.Name = Config.GetString("Name", Info.Name); Info.Name = Config.GetString("Name", Info.Name);
Info.Deck = Config.GetString("Deck", Info.Deck); Info.Deck = Config.GetString("Deck", Info.Deck);
Info.DeckFile = Config.GetString("DeckFile", Info.DeckFile); Info.DeckFile = Config.GetString("DeckFile", Info.DeckFile);
Info.DeckCode = Config.GetString("DeckCode", Info.DeckCode);
Info.Dialog = Config.GetString("Dialog", Info.Dialog); Info.Dialog = Config.GetString("Dialog", Info.Dialog);
Info.Host = Config.GetString("Host", Info.Host); Info.Host = Config.GetString("Host", Info.Host);
Info.Port = Config.GetInt("Port", Info.Port); Info.Port = Config.GetInt("Port", Info.Port);
...@@ -108,6 +109,9 @@ namespace WindBot ...@@ -108,6 +109,9 @@ namespace WindBot
string deckfile = HttpUtility.ParseQueryString(RawUrl).Get("deckfile"); string deckfile = HttpUtility.ParseQueryString(RawUrl).Get("deckfile");
if (deckfile != null) if (deckfile != null)
Info.DeckFile = deckfile; Info.DeckFile = deckfile;
string deckcode = HttpUtility.ParseQueryString(RawUrl).Get("deckcode");
if (deckcode != null)
Info.DeckCode = deckcode;
string dialog = HttpUtility.ParseQueryString(RawUrl).Get("dialog"); string dialog = HttpUtility.ParseQueryString(RawUrl).Get("dialog");
if (dialog != null) if (dialog != null)
Info.Dialog = dialog; Info.Dialog = dialog;
......
...@@ -7,6 +7,7 @@ namespace WindBot ...@@ -7,6 +7,7 @@ namespace WindBot
public string Name { get; set; } public string Name { get; set; }
public string Deck { get; set; } public string Deck { get; set; }
public string DeckFile { get; set; } public string DeckFile { get; set; }
public string DeckCode { get; set; }
public string Dialog { get; set; } public string Dialog { get; set; }
public string Host { get; set; } public string Host { get; set; }
public int Port { get; set; } public int Port { get; set; }
...@@ -20,6 +21,7 @@ namespace WindBot ...@@ -20,6 +21,7 @@ namespace WindBot
Name = "WindBot"; Name = "WindBot";
Deck = null; Deck = null;
DeckFile = null; DeckFile = null;
DeckCode = null;
Dialog = "default"; Dialog = "default";
Host = "127.0.0.1"; Host = "127.0.0.1";
Port = 7911; 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