//Кастуем хил private static async Task CastHeal(Person player, Magic magic, SocketCommandContext Context, string target) { //Если нет цели if (target == string.Empty) { player.p_Mana -= magic.cost; await player.GetHeal(magic.value, true); await Task.Run(() => Loging.Log(Context.User.Username + " подлечил себя способностью" + magic.name + " на " + magic.value + " и " + magic.effect, Context.Channel)); } else { var pTarget = Exeptioner.ValidPlayer(target, Context) ? PersonService.persons[target] : null; if (pTarget == null) { return; } player.p_Mana -= magic.cost; await pTarget.GetHeal(magic.value, true); await Task.Run(() => Loging.Log(Context.User.Username + " подлечил " + pTarget.name + " способностью " + magic.name + " на " + magic.value + " и " + magic.effect, Context.Channel)); } }
//Кастуем усиление private static async Task CastPowerUp(Person player, Magic magic, SocketCommandContext Context, string target) { //Если нет цели if (target == string.Empty) { player.p_Mana -= magic.cost; await player.ApplyStat(0, 0, magic.value, magic.value, magic.value); player.buffs.Add(new Buff(Buff.buffType.PowerUp, magic.value)); await Task.Run(() => Loging.Log(Context.User.Username + " кастанул " + magic.name + " на себя и " + magic.effect + " усилив себя на " + magic.value, Context.Channel)); } else { var pTarget = Exeptioner.ValidPlayer(target, Context) ? PersonService.persons[target] : null; if (pTarget == null) { return; } player.p_Mana -= magic.cost; await pTarget.ApplyStat(magic.value, magic.value, magic.value); pTarget.buffs.Add(new Buff(Buff.buffType.PowerUp, magic.value)); await Task.Run(() => Loging.Log(Context.User.Username + " кастанул " + magic.name + " на " + pTarget.name + " и тот " + magic.effect + " усилив на " + magic.value, Context.Channel)); } }
internal void run(string dispatcher_center_callback) { this.dispatcher_center_callback = dispatcher_center_callback; Loging.LogInformation <HpScheduleJob>("启动服务:" + this.getJobName()); this.listen(this.rabbitmq_url, this.jobKey); }
public JobApplication(HpScheduleOptions options = null) { if (options == null) { options = new HpScheduleOptions(); } //初始化日志 if (options.Nlog) { //Log.config(options.Log4net); Loging.setLogType(EnumLoging.LogConsole); //简单格式的Log // if (options.Debug) Log.SimpleFormat = true; } //初始化配置 if (!string.IsNullOrEmpty(options.Config)) { ConfigurationCenter.addConfigurationImpl(new JsonConfiguration(options.Config)); if (!ConfigurationCenter.load()) { throw new Exception("加载配置文件失败"); } } }
private void listen(string rabbitmq_url, string jobKey) { try { Loging.LogInformation <HpScheduleJob>("建立连接: " + rabbitmq_url + ", jobKey: " + jobKey); var consumer = mFactory.CreateMqConsumer(jobKey); Loging.LogInformation <HpScheduleJob>("监听MQ消息: " + jobKey); consumer.ReceivedMessage((deliveryTag, message) => { //Log.ContextName = this.GetType().ToString(); //Log.ContextID = Guid.NewGuid().ToString("D"); Loging.LogInformation <HpScheduleJob>(string.Format("收到消息[{0}-{1}]: {2}", this.getJobName(), jobKey, message)); HandleMsg(consumer, message, deliveryTag); // Log.ContextName = null; }); Loging.LogInformation <HpScheduleJob>("服务启动成功:" + this.getJobName()); } catch (Exception ex) { Loging.LogError <HpScheduleJob>(ex.ToString()); } }
public static async Task GetMagic(string text, SocketCommandContext Context) { try { string[] skillText = text.Split(","); if (skillText.Length > 1) { } else { var player = Exeptioner.ValidMe(Context)? PersonService.persons[Context.User.Username] : null; if (player == null) { return; } var magic = MagicService.magics[skillText[0]]; player.skills.Add(magic.name, magic); await Loging.Log(player.name + " изучил " + magic.name, Context.Channel); } } catch { await Loging.Log("Нет такой магии!", Context.Channel); } }
//Атата игроку private static async Task SetEnemy(SocketCommandContext Context, int indxChanel) { Person player = Exeptioner.ValidMe(Context) ? PersonService.persons[Context.User.Username] : null; if (player == null) { return; } if (player.fight != false) { return; } Random rand = new Random(); Mob mob = new Mob("Враг", rand.Next(player.p_Level - 2 < 1 ?1: player.p_Level - 2, player.p_Level + 3)); mob.room = ulong.Parse(player.lastRoom); await Loging.Log("Тебе повстречался : \n" + "Имя : " + mob.name + "\n" + "Уровень : " + mob.level + "\n" + "Здоровье : " + mob.hp + "\n" + "Атака : " + mob.damage, Context.Channel); enemys[indxChanel] = mob; player.fight = true; await AttackEnemy(Context); }
public VideoDetailsViewModel() { //NavCommand = new MyICommand<string>(OnNav); // FetchVideoCommand = new MyICommand<string>(OnFetchVideo); // DownloadPush = new MyICommand<string>(OnDownloadPush); OpenBrowser = new MyICommand <string>(OnBrowser); configRelayCommand_DownloadPush(); configRelayCommand_Browser(); configShowinFolderCommand(); configRemoveCommand(); configRemoveAllCommand(); initializeListVideoDetails(); configDownloadOneCommand(); configPlayCommand(); configStopCommand(); configStopAllCommand(); configRelayCommand_FetchVideoCommand(); if (VideoDetails.Count == 0) { var logList = Loging.Get(); if (logList != null) { VideoDetails = new ObservableCollection <Porter.Entity.VideoDetails>(logList); } } }
public static async Task ShowMyItems(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string inv = string.Empty; var invent = persons[Context.User.Username].items; foreach (KeyValuePair <string, Item> kp in invent) { inv += kp.Key + " : " + kp.Value.count + " шт.\n"; } if (inv == string.Empty) { await Loging.Log("В вашем инвентаре ничего нет", Context.Channel); } else { await Loging.Log("Ваш инвентарь :\n" + inv, Context.Channel); } }
public static async Task ShowMySkills(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string inv = string.Empty; var invent = persons[Context.User.Username].skills; foreach (KeyValuePair <string, Skill> kp in invent) { inv += "Название : " + kp.Value.name + "\n" + "Стоимость маны : " + kp.Value.cost + "\n"; } if (inv == string.Empty) { await Loging.Log("Вы ничего не знаете! Иди учись!", Context.Channel); } else { await Loging.Log("Ваши способности :\n" + inv, Context.Channel); } }
public static async Task BackToHome(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } var player = persons[Context.User.Username]; if (player.way == -1) { await Loging.Log("Ты уже дома!", Context.Channel); return; } if (player.fight) { await Loging.Log("Ты в бою!", Context.Channel); return; } TravelService.lockWay[player.way] = false; player.way = -1; await Loging.Log("Возвращаемся домой!", Context.Channel); }
public static async Task SetRang(string text, SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } if (Context.Channel.Name != "замок") { await Loging.Log("Назначение титула проводится исключительно в замке!", Context.Channel); return; } string[] rang = text.Split(","); try { var person = persons[rang[1]]; person.p_Titul = rang[0]; await Loging.Log(person.name + " теперь имеет титул " + rang[0], Context.Channel); } catch { await Loging.Log("Нет такого челика!", Context.Channel); } }
public static async Task ShowMyStats(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string text = string.Empty; try { var pi = persons[Context.User.Username]; text = "Имя : " + pi.name + "\n" + "Титул : " + pi.p_Titul + "\n" + "Класс : " + pi.p_Class + "\n" + "Здоровье : " + pi.p_Hp + "/" + pi.p_MaxHP + "\n" + "Мана : " + pi.p_Mana + "/" + pi.p_MaxMana + "\n" + "Уровень : " + pi.p_Level + "\n" + "Опыт : " + pi.p_Exp + "/" + pi.p_Exp_Need + "\n" + "Урон : " + pi.m_Attack + "\n" + "Защита : " + pi.m_Defence + "\n" + "Ловкость : " + pi.m_Agility + "\n" + "Сила : " + pi.m_Strength + "\n" + "Интелект : " + pi.m_Intelegence + "\n" + "Золото : " + pi.money + "\n"; await Loging.Log(text, Context.Channel); } catch { await Loging.Log("Вы не являетесь членом города Замарград", Context.Channel); } }
public static async Task Registration(SocketCommandContext Context) { if (Context.Channel.Name != "регистрационная-палата") { await Loging.Log("Регистрация проходит исключительно в регистрационной палате!", Context.Channel); return; } if (Exeptioner.ValidMe(Context, false)) { await Loging.Log("Вы уже являетесть членом этого города!", Context.Channel); return; } Person pi = new Person(Context.User.Id.ToString(), Context.User.Username.ToString()); pi.lastRoom = Context.Channel.Id.ToString(); persons.Add(pi.name, pi); string message = Context.User.Username.ToString() + " теперь полноправный член города!"; await Loging.Log(message, Context.Channel); }
public static async Task GiveItem(string text, SocketCommandContext Context) { string[] textArray = text.Split(","); if (!Exeptioner.ValidMe(Context) || !Exeptioner.ValidPlayer(textArray[1], Context)) { return; } try { if (textArray[1][0] == ' ') { textArray[1] = textArray[1].Substring(1); } var i = PersonService.persons[Context.User.Username].items[textArray[0]]; var p2 = PersonService.persons[textArray[1]].items.TryAdd(text, i); PersonService.persons[Context.User.Username].items.Remove(textArray[0]); await Loging.Log(Context.User.Username + " передал " + i.name + " " + textArray[1], Context.Channel); } catch { await Loging.Log("Так ничего не получится", Context.Channel); } }
public static bool ValidMe(SocketCommandContext Context, bool talk = true) { try { var p = PersonService.persons[Context.User.Username]; if (p.ghost && Context.Channel.Name != "духи") { Task.Run(() => Loging.Log("Дух " + Context.User.Username + " яростно машет руками и пытается что-то сделать.", Context.Channel)); return(false); } else { return(true); } } catch { if (talk) { Task.Run(() => Loging.Log("Ты не зарегестрирован в городе", Context.Channel)); } return(false); } }
public static async Task CreateAction(string text, SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string[] textArray = text.Split(","); //if (!Exeptioner.ValidMe(Context)) return; try { string name = textArray[0]; if (name[0] == ' ') { name = name.Substring(1); } string effect = textArray[1]; if (effect[0] == ' ') { effect = effect.Substring(1); } actions.Add(name, new Action(name, effect)); await Loging.Log("Теперь ты можешь " + name, Context.Channel); } catch { await Loging.Log("Не то ты говоришь", Context.Channel); } }
public async Task GetExp(int exp) { var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel; p_Exp += exp; if (p_Exp > p_Exp_Need) { int piceExp = p_Exp - p_Exp_Need; p_Exp = 0; p_Level++; p_Attack += 5; p_Defence += 2; p_Exp_Need = 20 * p_Level; await Loging.Log(name + " теперь " + p_Level + " уровня!", chanel); await ApplyStat(0, 0, 1, 1, 1); await GetExp(piceExp); return; } await Loging.Log(name + " получил " + exp + " опыта!", chanel); }
public static async Task UseAction(SocketCommandContext Context, string text) { string[] newText = text.Split(","); try { var a = actions[newText[0]]; if (newText.Length > 1) { if (newText[1][0] == ' ') { newText[1] = newText[1].Substring(1); } //var p = Exeptioner.ValidPlayer(newText[1], Context) ? PersonService.persons[newText[1]] : null; //if (p != null) await Task.Run(() => Loging.Log(Context.User.Username + " предложил " + newText[1] + " " + a.name, Context.Channel)); } else { await Task.Run(() => Loging.Log(Context.User.Username + " решил " + a.name + " после чего " + a.effect, Context.Channel)); } return; } catch { await Loging.Log("Не то ты говоришь", Context.Channel); } }
public static SortedDictionary <string, object> fromXML(string xml) { SortedDictionary <string, object> result = null; try { if (string.IsNullOrEmpty(xml)) { return(null); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode xmlNode = xmlDoc.FirstChild;//获取到根节点<xml> XmlNodeList nodes = xmlNode.ChildNodes; result = new SortedDictionary <string, object>(); foreach (XmlNode xn in nodes) { XmlElement xe = (XmlElement)xn; result[xe.Name] = xe.InnerText;//获取xml的键值对到WxPayData内部的数据中 } } catch (Exception e) { result = null; Loging.LogError(e.ToString()); } return(result); }
public static async Task MakeShop(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } if (Context.Channel.Name != "рынок") { await Loging.Log("Товар можно купить только на рынке!", Context.Channel); return; } string all = string.Empty; for (int i = 0; i < items.Count; i++) { all += "[" + i + "] | " + "Название : " + items[i].name + " | Цена : " + items[i].cost + "\n"; } if (all == string.Empty) { all = "На рынке нет товаров!"; } await Loging.Log(all, Context.Channel); }
public static async Task GetPower(string text, SocketCommandContext Context) { try { string[] skillText = text.Split(","); if (skillText.Length > 1) { } else { var player = Exeptioner.ValidMe(Context) ? PersonService.persons[Context.User.Username] : null; if (player == null) { return; } var power = PowerService.powers[skillText[0]]; player.skills.Add(power.name, power); await Loging.Log(player.name + " изучил " + power.name, Context.Channel); } } catch { await Loging.Log("Нет такого усиления!", Context.Channel); } }
public static async Task ShowMyBaffs(SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string inv = string.Empty; var invent = persons[Context.User.Username].buffs; foreach (Buff kp in invent) { inv += "Тип : " + kp.type + "\n" + "Значение : " + kp.value + "\n" + "Осталось времени сек : " + kp.time + "\n"; } if (inv == string.Empty) { await Loging.Log("На вас нет бафов!", Context.Channel); } else { await Loging.Log("Бафы на вас :\n" + inv, Context.Channel); } }
//Создаем магию public static async Task CreateMagic(string text, SocketCommandContext Context) { if (!Exeptioner.ValidMe(Context)) { return; } string[] textArray = text.Split(","); if (Context.Channel.Name != "школа-магических-исскуств") { await Loging.Log("Магию можно создавать только в школе магических исскуств", Context.Channel); return; } try { string type = textArray[0]; string name = textArray[1]; if (name[0] == ' ') { name = name.Substring(1); } int value = int.Parse(textArray[2]); string effect = textArray[3]; if (effect[0] == ' ') { effect = effect.Substring(1); } switch (type) { case "лечение": magics.Add(name, new Magic(Magic.magicType.Heal, name, value, effect)); break; case "урон": magics.Add(name, new Magic(Magic.magicType.Damage, name, value, effect)); break; case "усиление": magics.Add(name, new Magic(Magic.magicType.PowerUp, name, value, effect)); break; default: break; } await Loging.Log("Заклинание " + name + " готово", Context.Channel); } catch { await Loging.Log("Не то ты говоришь", Context.Channel); } }
private OperationResult <Loging> OperationResultOperation(Loging logModel, bool status) { var result = new OperationResult <Loging>(); result.Model = logModel; result.Messages.Add(status != true ? "Error" : "Success"); result.Success = status; return(result); }
//Нашел лут! private static async Task FindLoot(Person player, SocketCommandContext Context) { Random rand = new Random(); int exp = rand.Next(20, 50); await player.GetExp(exp); await Loging.Log("Ты нашел мешочек с " + exp + " опыта!", Context.Channel); }
private static async Task LogPower(SocketCommandContext Context, Power power, Person player, Person target = null) { if (target != null) { await Loging.Log(player.name + " использовал усиление " + power.name + " повысив " + power.type + " на " + power.value + " у игрока" + target.name + " и он " + power.effect, Context.Channel); } else { await Loging.Log(player.name + " использовал усиление " + power.name + " повысив " + power.type + " на " + power.value + " и он " + power.effect, Context.Channel); } }
private void configRemoveCommand() { RemoveCommand = new RelayCommand(async o => { if (o != null && !string.IsNullOrEmpty(((Porter.Entity.VideoDetails)o).Url)) { //int index; bool deletedDone = await Loging.Remove(VideoDetails, ((Porter.Entity.VideoDetails)o).Url);//, out index } }, o => true); }
private void configRemoveAllCommand() { RemoveAllCommand = new RelayCommand(o => { if (Loging.RemoveAll()) { for (int i = VideoDetails.Count - 1; i >= 0; i--) { VideoDetails.RemoveAt(i); } } }, o => true); }
public async Task Resurrection() { var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel; await Task.Run(() => { p_Hp = p_MaxHP; p_Mana = p_MaxMana; ghost = false; }); await Loging.Log(name + " снова в теле!", chanel); }
public void SetUp() { repository=new MockRepository(); Log = repository.CreateMock<Loging>(); }