Ejemplo n.º 1
0
        public async Task <ActionResult <JournalLog> > PostJournalLog(JournalLog journalLog)
        {
            _context.JournalLogs.Add(journalLog);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetJournalLog", new { id = journalLog.Id }, journalLog));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutJournalLog(string id, JournalLog journalLog)
        {
            if (id != journalLog.Id)
            {
                return(BadRequest());
            }

            _context.Entry(journalLog).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JournalLogExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public QuestActionStructure(QuestAction current, ILoggable updateLogs)
        {
            hasActionOnComplete = new Dictionary <QuestAction, bool>();
            hasActionOnFail     = new Dictionary <QuestAction, bool>();
            currentAction       = current;
            _actionChanged      = new BehaviorSubject <QuestAction>(current);
            ActionChanged().Subscribe((action) =>
            {
                #region Structure Logs
                currentAction = action;
                action.SetActive();

                JournalLog currentLog = updateLogs.AddDiscreteLogWrapper(action.TaskName(), action.TaskDescription(), action.StartProgress(), action.Target());
                action.UpdateScore().Subscribe((score) =>
                {
                    if (!currentLog.HasBeenCompleted())
                    {
                        currentLog.UpdateCurrentProgress(score > currentLog.Range ? currentLog.Range : score);
                    }
                });
                action.logUpdated.Subscribe((log) =>
                {
                    updateLogs.AddLogWrapper(log);
                });
                #endregion
                #region Structure Completion status
                action.OnComplete().Subscribe((x) =>
                {
                    if (x)
                    {
                        if (!hasActionOnComplete.ContainsKey(action))
                        {
                            completeSubject.OnNext(true);
                        }
                    }
                });

                action.OnFail().Subscribe((x) =>
                {
                    if (x)
                    {
                        if (!hasActionOnFail.ContainsKey(action))
                        {
                            failSubject.OnNext(true);
                        }
                    }
                });
                #endregion
            });
        }
 private void OnQuestStarted(QuestBase quest)
 {
     if (quest.StringId == "investigate_neretzes_banner_quest" && CSCharCreationOption.CSGameOption == 1)
     {
         AccessTools.Method(typeof(QuestBase), "CompleteQuestWithSuccess").Invoke(quest, null);
     }
     if (quest.StringId == "main_storyline_create_kingdom_quest_1" || quest.StringId == "main_storyline_create_kingdom_quest_0")
     {
         if (Clan.PlayerClan.Kingdom != null)
         {
             if (Clan.PlayerClan.Kingdom.RulingClan == Clan.PlayerClan)
             {
                 Type       type = AccessTools.TypeByName("StoryMode.Behaviors.Quests.FirstPhase.CreateKingdomQuestBehavior+CreateKingdomQuest");
                 JournalLog log  = (JournalLog)AccessTools.Field(type, "_clanIndependenceRequirementLog").GetValue(quest);
                 AccessTools.Field(type, "_hasPlayerCreatedKingdom").SetValue(quest, true);
                 Object[] parameters = new object[] { log, 1 };
                 AccessTools.Method(typeof(QuestBase), "UpdateQuestTaskStage").Invoke(quest, parameters);
             }
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Formats the database with provider.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="databaseName">Name of the database, maximum 63 characters long.</param>
        /// <param name="blockCount">The block count.</param>
        /// <param name="journalSectorFreq">The journal frequency.</param>
        /// <param name="journalSize">Size of the journal.</param>
        /// <param name="journalFrequency">The journal frequency, meaning depends on sector frequency.</param>
        /// <returns></returns>
        public unsafe static bool Format(IProvider provider, string databaseName, ulong blockCount,
                                         uint journalFrequency)
        {
            if (databaseName == null || databaseName == string.Empty || databaseName.Length > 63)
            {
                throw new ArgumentException("Database name was either invalid or too long.");
            }

            // 1) We first enlarge the provider (must be at least that long).
            if (!provider.Enlarge(blockCount))
            {
                return(false);
            }

            // 2) We create the header node.
            Block block = new Block(provider.BlockSize);

            fixed(byte *p = block.Data)
            {
                DatabaseHeader *header = (DatabaseHeader *)p;

                header->BlockSize         = provider.BlockSize;
                header->BlockCount        = blockCount;
                header->HeaderMagic1      = DatabaseHeader.Magic1;
                header->HeaderMagic2      = DatabaseHeader.Magic2;
                header->JournalFrequency  = journalFrequency;
                header->RootObjectAddress = 0;

                // Copy the name.
                int i;

                for (i = 0; i < databaseName.Length; i++)
                {
                    header->DatabaseName[i] = databaseName[i];
                }
                header->DatabaseName[i] = '\0';
            }

            // We write it.
            provider.Write(0, block.Data);

            // Make an empty (zero block).
            block.ZeroMemory();

            // The one allocated block.
            Block fullBlock = new Block(provider.BlockSize);

            fullBlock.ZeroMemory();
            BoolArray fullBlockArray = new BoolArray(fullBlock.Data);

            fullBlockArray[0] = true;

            // 3) We clear allocation blocks.
            for (ulong superBlock = BlockHelper.FirstSuperBlockAddress; superBlock != 0;
                 superBlock = BlockHelper.GetNextSuperBlock(provider.BlockSize, superBlock, blockCount))
            {
                provider.Write(superBlock, block.Data);
            }

            for (ulong allocBlock = BlockHelper.FirstSuperBlockAddress + 1; allocBlock != 0;
                 allocBlock = BlockHelper.GetNextAllocationBlock(provider.BlockSize, allocBlock, blockCount))
            {
                if (JournalLog.IsJournalLog(allocBlock + 1, journalFrequency, provider.BlockSize))
                {
                    // We write the allocated.
                    provider.Write(allocBlock, fullBlock.Data);

                    // Next block is filled with header.
                    if (allocBlock + 1 < blockCount)
                    {
                        provider.Write(allocBlock + 1, block.Data);
                    }
                }
                else
                {
                    provider.Write(allocBlock, block.Data);
                }
            }


            return(true);
        }
 private static JournalLogViewModel JournalViewConverter(JournalLog journalLog)
 {
     return(new JournalLogViewModel {
         Date = journalLog.Date.AddDays(1)
     });
 }