private void CheckIfSpecialSquare(MapSection[][] map, int i, int j, int positionNumber, Character character, int roomId) { //Character moves back by 3 positions if he is on GoBackSquare if (map[i][j].isGoBackSquare) { Console.WriteLine("Oops, it seems you stopped on a special square..."); positionNumber -= 3; if (j >= 3) { if (j == 3) { j = 0; } else { j -= 3; } } else { var toTakeDown = 3 - j; if (i == 0) { throw new ArgumentException($"Cannot move back from {i}{j}"); } else { i -= 1; j = map[i].Length - 1; toTakeDown--; j -= toTakeDown; } } positionNumber = map[i][j].Number; UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId); Console.WriteLine($"{character.Name} moves back by 3 positions to square number {positionNumber} :)"); CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId); } //Character goes forward by 3 positions if he is on GoBackSquare else if (map[i][j].isGoForwardSquare) { Console.WriteLine("Oops, it seems you stopped on a special square..."); positionNumber += 3; if (j <= 6) { j += 3; } else //if(j != 9) { var thisRowAdd = 9 - j; var nextRowAdd = 3 - thisRowAdd; if (i == map.Length - 1) { throw new ArgumentException($"Cannot move forward from {i}{j}"); } else { i += 1; j = 0; if (j == 0) { nextRowAdd--; } j += nextRowAdd; } } positionNumber = map[i][j].Number; UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId); Console.WriteLine($"{character.Name} moves forward with 3 positions to square number {positionNumber} ^.^"); CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId); } //ToDo else if (map[i][j].isMysterySquare) { Console.WriteLine("Oops, it seems you stopped on a special square..."); var num = numberGenerator.GenerateNumber(1, 3); if (num == 1) { //play mini game //Can be found in Miscellaneous/SpecialSquares/MysterySquare/MiniGameAction.cs MiniGameAction msa = new MiniGameAction(); msa.PlayMiniGame(isSingle); if (msa.DemolitionFalcons) { //All characters return to the first square var characters = context.GameCharacters.Where(g => g.GameId == roomId).ToList(); foreach (var charche in characters) { context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).CharacterPositionX = map[0][0].X; context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).CharacterPositionY = map[0][0].Y; context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).MapSectionNumber = map[0][0].Number; context.SaveChanges(); } } else if (msa.GoBack) { var toGoBackWith = msa.GoBackWith; positionNumber -= toGoBackWith; if (j >= toGoBackWith) { if (j == toGoBackWith) { j = 0; } else { j -= toGoBackWith; } } else { var toTakeDown = toGoBackWith - j; if (i == 0) { throw new ArgumentException($"Cannot move back from {i}{j}"); } else { i -= 1; j = map[i].Length - 1; toTakeDown--; j -= toTakeDown; } } positionNumber = map[i][j].Number; UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId); Console.WriteLine($"{character.Name} moves back by {toGoBackWith} positions to square number {positionNumber} :)"); CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId); } else if (msa.MoveForward) { var toMoveForwardWith = msa.MoveForwardWith; positionNumber += toMoveForwardWith; if (j < map[i].Length - toMoveForwardWith) { j += toMoveForwardWith; } else //if(j != 9) { var thisRowAdd = 9 - j; var nextRowAdd = toMoveForwardWith - thisRowAdd; if (i == map.Length - 1) { throw new ArgumentException($"Cannot move forward from {i}{j}"); } else { i += 1; j = 0; if (j == 0) { nextRowAdd--; } j += nextRowAdd; } } positionNumber = map[i][j].Number; UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId); Console.WriteLine($"{character.Name} moves forward with {toMoveForwardWith} positions to square number {positionNumber} ^.^"); CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId); } } else { var doubleChance = new DoubleChance(); var isSingle = true; doubleChance.StartDoubleChance(context, roomId, character, positionNumber, map, i, j, isSingle); } } //ToDo else if (map[i][j].isBonusSquare) { Console.WriteLine("Oops, it seems you stopped on a special square..."); Console.WriteLine($"{character.Name} is on a bonus square :)"); BonusSquareAction bsa = new BonusSquareAction(context, roomId, character); //Gets a random spell drawn with a special algorythm that allow the character to atack another character bsa.GetSpell(""); } }
public void startAction(Player perso, MiniGameAction GA) { if (GA == null) { return; } int actionID = -1; short CcellID = -1; try { actionID = int.Parse(GA._args.Split(';')[1]); CcellID = short.Parse(GA._args.Split(';')[0]); } catch (Exception e) { Logger.Error(e); } if (actionID == -1) { return; } //Verif JobAction ? switch ((MiniGameActionEnum)actionID) { case MiniGameActionEnum.SAVE_POS: String str = this.Map + "," + this.Id; perso.SavePos = str; perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.INFO, 6)); break; case MiniGameActionEnum.USE_ZAAP: perso.openZaapMenu(); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.USE_ZAAPI: perso.openZaapiMenu(); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.PUISER: if (!Object.isInteractive()) { perso.GetClient().Send(new BasicNoOperationMessage()); return; } if (Object.getState() != (int)IObjectEnum.STATE_FULL) { perso.GetClient().Send(new BasicNoOperationMessage()); return; //Si le puits est vide } Object.setState((int)IObjectEnum.STATE_EMPTYING); Object.setInteractive(false); perso.myMap.SendToMap(new MapGameActionMessage(GA._id, 501, perso.ID + "", this.Id + "," + Object.getUseDuration() + "," + Object.getUnknowValue())); perso.myMap.SendToMap(new GameMapObjectMessage(perso.myMap)); break; case MiniGameActionEnum.RETURN_TO_INCARNAM: if (perso.Level > 15) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 127)); perso.GetClient().miniActions.Remove(GA._id); return; } //TODO Map By Perso perso.Teleport(MapTable.Get(10298), 314); perso.GetClient().miniActions.Remove(GA._id); break; case MiniGameActionEnum.ACCESS_TO_MOUNTPARK: if (Object.getState() != (int)IObjectEnum.STATE_EMPTY) { ; } if (perso.Deshonor >= 5) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 83)); perso.GetClient().miniActions.Remove(GA._id); return; } perso.inMountPark = perso.myMap.mountPark; perso.isAaway = true; perso.Send(new GameActionEnvironementMessage(16, perso.GetClient().Account.parseDragoList())); break; case MiniGameActionEnum.BUY_MOUNTPARK: MountPark MP = perso.myMap.mountPark; if (MP.get_owner() == -1) //Public { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 96)); return; } if (MP.get_price() == 0) //Non en vente { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 97)); return; } if (!perso.HasGuild()) //Pas de guilde { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 135)); return; } if (perso.getCharacterGuild().Grade != 1) //Non meneur { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 98)); return; } perso.Send(new GameRideMessage("D" + MP.get_price() + "|" + MP.get_price())); break; case MiniGameActionEnum.SELL_MOUNTPARK: case MiniGameActionEnum.SET_MOUNTPARK_PRICE: MountPark MP1 = perso.myMap.mountPark; if (MP1 == null) { return; } if (MP1.get_owner() == -1) //Public { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 94)); return; } if (MP1.get_owner() != perso.ID) { perso.Client.Send(new TextInformationMessage(TextInformationTypeEnum.ERREUR, 95)); return; } perso.Send(new GameRideMessage("D" + MP1.get_price() + "|" + MP1.get_price())); break; default: Logger.Error("Case.startAction non definie pour l'actionID = " + actionID); break; } }