Esempio n. 1
0
        public override InvestmentData Invest(double money, History hist, int roundNum)
        {
            checkIfInitilized();

            int stockId = getStockId(money, hist, roundNum);

            DebugFileWriter.writeToFile("output.txt", stockId.ToString());

            InvestmentData result = makeInvestment(money, roundNum, stockId, _isTrain);

            return(result);
        }
Esempio n. 2
0
    public void TestWriteCodeUnit()
    {
        ICodeWriter writer = new DebugFileWriter();

        using (var stream = new StringWriter())
        {
            var units = new List <IUnit>();
            units.Add(new TextUnit("Code"));

            writer.Write(stream, units);
            string output = stream.ToString();

            Assert.IsTrue(output.StartsWith("Code"));
        }

        Assert.Pass();
    }
    public static void WriteToFile(List <SpawnSystem.SpawnData> spawners, string fileName, bool postChange = false)
    {
        try
        {
            if (spawners is null)
            {
                return;
            }

            List <string> lines = new List <string>(spawners.Count * 30);

            AddIntroToFile(lines);

            for (int i = 0; i < spawners.Count; ++i)
            {
                var spawner = spawners[i];

                if (spawner is not null)
                {
                    lines.AddRange(WriteSpawner(spawner, i, postChange));
                }
                else
                {
                    //Empty spawner. Just add the index and continue.
                    lines.Add($"[WorldSpawner.{i}]");
                    lines.Add($"## Spawner is empty for unknown reasons.");
                    lines.Add($"");
                }
            }

            DebugFileWriter.WriteFile(lines, fileName, "world spawner configurations");
        }
        catch (Exception e)
        {
            Log.LogWarning($"Error while trying to write world spawner debug file '{fileName}'.", e);
        }
    }
Esempio n. 4
0
    public void Print(string filename, string description = null)
    {
        image.Apply();

        DebugFileWriter.WriteFile(image.EncodeToPNG(), filename + ".png", description ?? "map");
    }
Esempio n. 5
0
    public static void WriteToFile(List <DungeonDB.RoomData> rooms)
    {
        List <string> spawnersSerialized = new List <string>();

        if (rooms is null)
        {
            Log.LogWarning("Rooms are null");
            return;
        }

        if (rooms.Count == 0)
        {
            Log.LogWarning("No rooms to write.");

            return;
        }

        try
        {
            foreach (var room in rooms
                     .Select(x => x.m_room)
                     .OrderBy(x => x.m_theme)
                     .ThenBy(x => x.name))
            {
                if (room.gameObject == null)
                {
                    Log.LogTrace($"Room {room.name} gameobject is null");
                }
            }
        }
        catch (Exception e)
        {
            Log.LogError("Wtf?", e);
        }

        var orderedRooms = rooms
                           .Select(x => x.m_room)
                           .OrderBy(x => x.m_theme)
                           .ThenBy(x => x.name);

        foreach (var room in orderedRooms)
        {
            var roomPrefab = room;

            if (roomPrefab is null)
            {
#if DEBUG
                Log.LogDebug($"No gameobject for room {room.name}");
#endif
                continue;
            }

            var spawners = roomPrefab.GetComponentsInChildren <CreatureSpawner>();

            if (spawners is null)
            {
#if DEBUG
                Log.LogDebug($"No spawners for room {room.name}");
#endif
                continue;
            }

            if (spawners != null && spawners.Length > 0)
            {
                spawnersSerialized.Add(Serialize(room, spawners));
            }
        }

        DebugFileWriter.WriteFile(spawnersSerialized, FileName, "local dungeon spawner configurations");
    }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     dfw = GetComponent <DebugFileWriter>();
 }
    public static void WriteToFile(List <ZoneSystem.ZoneLocation> zoneLocations)
    {
        List <string> spawnersSerialized = new List <string>();

        var orderedLocations = zoneLocations
                               .OrderBy(x => x.m_biome)
                               .ThenBy(x => x.m_prefabName);

        foreach (var location in orderedLocations)
        {
            var locPrefab = location.m_prefab;

            if (locPrefab is null)
            {
                continue;
            }

            //Get location spawners
            var spawners = locPrefab.GetComponentsInChildren <CreatureSpawner>().ToList();

            //Get location dungeon generators, so we can scan for their spawners too
            var dungeons = locPrefab.GetComponentsInChildren <DungeonGenerator>();

            if (dungeons is not null && dungeons.Length > 0)
            {
                foreach (var dungeon in dungeons)
                {
                    //Find rooms and extract spawners
                    var rooms = DungeonDB.GetRooms().Where(x => (x.m_room.m_theme & dungeon.m_themes) == x.m_room.m_theme).ToList();

                    if (rooms.Count == 0)
                    {
                        Log.LogDebug($"No rooms for {locPrefab.name}:{dungeon.name}");
                    }


                    var roomSpawners = rooms
                                       .SelectMany(x => x.m_room.GetComponentsInChildren <CreatureSpawner>())
                                       .Where(x => x is not null)
                                       .ToList();

                    if (roomSpawners.Count > 0)
                    {
                        if (spawners is null)
                        {
                            spawners = roomSpawners;
                        }
                        else
                        {
                            spawners.AddRange(roomSpawners);
                        }
                    }
                    else
                    {
                        Log.LogDebug($"No room spawners for {locPrefab.name}:{dungeon.name}");
                    }
                }
            }

            if (spawners is not null && spawners.Count > 0)
            {
                spawnersSerialized.Add(Serialize(location, spawners));
            }
        }

        DebugFileWriter.WriteFile(spawnersSerialized, FileName, "local spawner configurations");
    }