Esempio n. 1
0
 public Tag CreateOrFindTag(String tagname)
 {
     Tag tag = this.provider.Database.Tags.GetTagByTagname(tagname);
     if (tag == null)
     {
         tag = new Tag { TagId = Guid.NewGuid(), TagName = tagname };
         provider.Database.Tags.Add(tag);
     }
     return tag;
 }
Esempio n. 2
0
 public void AddTask(TaskModel model)
 {
     using (var db = new DataContext())
     {
          var tag = new Tag {TagId = Guid.NewGuid(), TagName = "dasd"};
         var newTask = new Task
                            {
                                TaskId = Guid.NewGuid(),
                                Title = model.Title,
                                CreationDate = DateTime.UtcNow,
                            };
         db.Tags.Add(tag);
         newTask.Tags.Add(tag);
         var userProvider = new UserProvider();
         userProvider.GetCurrentUser(db).Tasks.Add(newTask);
         newTask.UserOwner = userProvider.GetCurrentUser(db);
         db.Tasks.Add(newTask);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 private void TryHandleTurnTag(Tag tag)
 {
     if (string.Equals(tag.Name, "TURN"))
     {
         CurrentTurnIndex = int.Parse(tag.Value);
     }
 }
Esempio n. 4
0
 private void TryHandleStepTag(Tag tag)
 {
     if (!isMulliganDone)
         return;
     if (string.Equals(tag.Name, "STEP") &&
         string.Equals(tag.Value, "MAIN_READY"))
     {
         CurrentTurn = new Turn();
         CurrentTurn.Player = CurrentPlayer;
         CurrentTurn.TurnIndex = CurrentTurnIndex;
         game.Turns.Add(CurrentTurn);
     }
 }
Esempio n. 5
0
 private void TryHandleMulliganTag(Tag tag)
 {
     if (string.Equals(tag.Name, "MULLIGAN_STATE") &&
         string.Equals(tag.Value, "DONE"))
     {
         mulliganFinisherIndex++;
         if (mulliganFinisherIndex == 2)
             this.isMulliganDone = true;
     }
 }
Esempio n. 6
0
 private void TryHandleCurrentPlayerTag(Tag tag)
 {
     if (string.Equals(tag.Name, "CURRENT_PLAYER") &&
         string.Equals(tag.Value, "1"))
     {
         CurrentPlayer = tag.Entity.Name;
     }
 }
Esempio n. 7
0
 private Tag ParseTag(string tagString)
 {
     var tag = new Tag();
     var tagRegex = new Regex(@"Entity=(\[name=(?<entityname>[\w\s\dа-яА-Я_-]+)\sid=(?<entityid>\d+)\szone=(?<entityzone>\w+)\szonePos=(?<entityzonepos>\d)\scardId=(?<entitycardid>[\w\d_]+)\splayer=(?<entityplayer>\d)\]|\[id=(?<xentityid>\d+)\scardId=\stype=INVALID\szone=(?<xentityzone>\w*)\szonePos=(?<xentityzonepos>\d+)\splayer=(?<xentityplayer>\d)\]|(?<entity>[\w\s\d_-]*)) tag=(?<tag>[\w\s\d_-]*) value=(?<value>[\w\s\d_-]*)");
     var match = tagRegex.Match(tagString);
     tag.Entity = new Entity();
     tag.IsConsistent = true;
     int entityId;
     if (!string.IsNullOrEmpty(match.Groups["entityid"].Value) &&
         int.TryParse(match.Groups["entityid"].Value, out entityId))
     {
         tag.Entity.Id = entityId;
         tag.Entity.Name = match.Groups["entityname"].Value;
         tag.Entity.CardId = match.Groups["entitycardid"].Value;
         tag.Entity.Zone = match.Groups["entityzone"].Value;
         tag.Entity.ZonePos = int.Parse(match.Groups["entityzonepos"].Value);
         tag.Entity.Player = int.Parse(match.Groups["entityplayer"].Value);
     }
     else if (!string.IsNullOrEmpty(match.Groups["xentityid"].Value) &&
         int.TryParse(match.Groups["xentityid"].Value, out entityId))
     {
         tag.Entity.Id = entityId;
         tag.Entity.Zone = match.Groups["xentityzone"].Value;
         tag.Entity.ZonePos = int.Parse(match.Groups["xentityzonepos"].Value);
         tag.Entity.Player = int.Parse(match.Groups["xentityplayer"].Value);
     }
     else
     {
         tag.Entity.Name = match.Groups["entity"].Value;
     }
     tag.Name = match.Groups["tag"].Value;
     tag.Value = match.Groups["value"].Value;
     tag.Value = tag.Value.Trim();
     return tag;
 }
Esempio n. 8
0
 private void HandleTagChange(Tag tag)
 {
     TryHandleMulliganTag(tag);
     TryHandleTurnTag(tag);
     TryHandleStepTag(tag);
     TryHandleCurrentPlayerTag(tag);
 }
Esempio n. 9
0
 public TagsModel GetModel(Tag tag)
 {
     return new TagsModel {TagName = tag.TagName};
 }