Line data Source code
1 : package mapplanner
2 :
3 : import (
4 : "github.com/kijimaD/ruins/internal/rawschema"
5 : )
6 :
7 : // testLayoutTiles はテスト用の間取りのタイル
8 : var testLayoutTiles = rawschema.LayoutTiles{Floor: "floor", Wall: "wall", Void: "void"}
9 :
10 : // CreateTestRawMaster はテスト用の rawschema.Raws インスタンスを作成する
11 : func CreateTestRawMaster() *rawschema.Raws {
12 : // テスト用の基本的なタイルデータを定義
13 1 : autotile := &rawschema.TileSpawn{Autotile: true}
14 1 : testTiles := []rawschema.Tile{
15 1 : {Id: "wall", Name: "wall", BlockPass: true, SpriteRender: rawschema.SpriteRender{Depth: rawschema.N3}, Spawn: &rawschema.TileSpawn{Tile: new("dwall"), Autotile: true}},
16 1 : {Id: "floor", Name: "floor", BlockPass: false, Spawn: autotile},
17 1 : {Id: "road", Name: "road", BlockPass: false, Spawn: autotile},
18 1 : {Id: "dirt", Name: "dirt", BlockPass: false, Spawn: autotile},
19 1 : {Id: "void", Name: "void", BlockPass: true, SpriteRender: rawschema.SpriteRender{Depth: rawschema.N3}, Spawn: &rawschema.TileSpawn{}},
20 1 : {Id: "deep_water", Name: "deep_water", BlockPass: true, Spawn: &rawschema.TileSpawn{}},
21 1 : {Id: "bridge_a", Name: "bridge_a", BlockPass: false, Spawn: autotile},
22 1 : {Id: "bridge_b", Name: "bridge_b", BlockPass: false, Spawn: autotile},
23 1 : {Id: "bridge_c", Name: "bridge_c", BlockPass: false, Spawn: autotile},
24 1 : {Id: "bridge_d", Name: "bridge_d", BlockPass: false, Spawn: autotile},
25 1 : }
26 :
27 : // テスト用のアイテムテーブルを定義
28 1 : testItemTables := []rawschema.ItemTable{
29 1 : {
30 1 : Id: "normal",
31 1 : Name: "normal",
32 1 : Entries: []rawschema.ItemTableEntry{
33 1 : {Id: "healing_items", Weight: 1.0, MinDanger: 1, MaxDanger: 20},
34 1 : {Id: "ores", Weight: 0.5, MinDanger: 3, MaxDanger: 40},
35 1 : },
36 1 : },
37 1 : {
38 1 : Id: "cave",
39 1 : Name: "cave",
40 1 : Entries: []rawschema.ItemTableEntry{
41 1 : {Id: "healing_items", Weight: 1.0, MinDanger: 1, MaxDanger: 20},
42 1 : {Id: "ores", Weight: 0.6, MinDanger: 3, MaxDanger: 25},
43 1 : },
44 1 : },
45 1 : {
46 1 : Id: "forest",
47 1 : Name: "forest",
48 1 : Entries: []rawschema.ItemTableEntry{
49 1 : {Id: "healing_items", Weight: 1.0, MinDanger: 1, MaxDanger: 15},
50 1 : },
51 1 : },
52 1 : {
53 1 : Id: "ruins",
54 1 : Name: "ruins",
55 1 : Entries: []rawschema.ItemTableEntry{
56 1 : {Id: "healing_items", Weight: 1.0, MinDanger: 1, MaxDanger: 15},
57 1 : {Id: "ores", Weight: 0.8, MinDanger: 3, MaxDanger: 20},
58 1 : },
59 1 : },
60 1 : }
61 :
62 : // テスト用の敵テーブルを定義
63 1 : testEnemyTables := []rawschema.EnemyTable{
64 1 : {
65 1 : Id: "normal",
66 1 : Name: "normal",
67 1 : Entries: []rawschema.EnemyTableEntry{
68 1 : {Id: "slime", Weight: 1.2, MinDanger: 1, MaxDanger: 10, Pack: "1d1"},
69 1 : {Id: "fireball", Weight: 1.0, MinDanger: 1, MaxDanger: 20, Pack: "1d1"},
70 1 : {Id: "light_tank", Weight: 0.8, MinDanger: 10, MaxDanger: 50, Pack: "1d1"},
71 1 : },
72 1 : },
73 1 : {
74 1 : Id: "cave",
75 1 : Name: "cave",
76 1 : Entries: []rawschema.EnemyTableEntry{
77 1 : {Id: "slime", Weight: 1.0, MinDanger: 1, MaxDanger: 8, Pack: "1d1"},
78 1 : {Id: "fireball", Weight: 1.0, MinDanger: 1, MaxDanger: 15, Pack: "1d1"},
79 1 : {Id: "light_tank", Weight: 0.6, MinDanger: 8, MaxDanger: 25, Pack: "1d1"},
80 1 : },
81 1 : },
82 1 : {
83 1 : Id: "forest",
84 1 : Name: "forest",
85 1 : Entries: []rawschema.EnemyTableEntry{
86 1 : {Id: "slime", Weight: 1.2, MinDanger: 1, MaxDanger: 12, Pack: "1d1"},
87 1 : {Id: "fireball", Weight: 1.0, MinDanger: 1, MaxDanger: 15, Pack: "1d1"},
88 1 : {Id: "light_tank", Weight: 0.5, MinDanger: 10, MaxDanger: 20, Pack: "1d1"},
89 1 : },
90 1 : },
91 1 : {
92 1 : Id: "ruins",
93 1 : Name: "ruins",
94 1 : Entries: []rawschema.EnemyTableEntry{
95 1 : {Id: "slime", Weight: 0.9, MinDanger: 1, MaxDanger: 10, Pack: "1d1"},
96 1 : {Id: "fireball", Weight: 0.8, MinDanger: 1, MaxDanger: 20, Pack: "1d1"},
97 1 : {Id: "light_tank", Weight: 1.0, MinDanger: 5, MaxDanger: 30, Pack: "1d1"},
98 1 : {Id: "ash_idol", Weight: 0.7, MinDanger: 15, MaxDanger: 35, Pack: "1d1"},
99 1 : },
100 1 : },
101 1 : }
102 :
103 : // テスト用のアイテムグループを定義
104 1 : testItemGroups := []rawschema.ItemGroup{
105 1 : {
106 1 : Id: "healing_items",
107 1 : Name: "healing_items",
108 1 : Entries: []rawschema.ItemGroupEntry{
109 1 : {Id: "healing_potion", Weight: 1.0, Pack: "1d3"},
110 1 : {Id: "antidote", Weight: 0.5, Pack: "1d1"},
111 1 : },
112 1 : },
113 1 : }
114 1 : testItemCollections := []rawschema.ItemCollection{
115 1 : {
116 1 : Id: "ores",
117 1 : Name: "ores",
118 1 : Entries: []rawschema.ItemCollectionEntry{
119 1 : {Id: "obsidian", Chance: 50, Pack: "1d2"},
120 1 : {Id: "silver_shard", Chance: 30, Pack: "1d1"},
121 1 : },
122 1 : },
123 1 : }
124 :
125 : // テスト用のアイテム定義(スタック判定に必要)
126 :
127 1 : return &rawschema.Raws{
128 1 : Tiles: &testTiles,
129 1 : Items: &[]rawschema.Item{
130 1 : {Id: "healing_potion", Name: "healing_potion", Description: "restores HP"},
131 1 : {Id: "antidote", Name: "antidote", Description: "cures poison"},
132 1 : {Id: "obsidian", Name: "obsidian", Description: "a black stone"},
133 1 : {Id: "silver_shard", Name: "silver_shard", Description: "silver_shard"},
134 1 : {Id: "herb", Name: "herb", Description: "herb"},
135 1 : {Id: "wooden_sword", Name: "wooden_sword", Description: "a wooden sword"},
136 1 : },
137 1 : ItemGroups: &testItemGroups,
138 1 : ItemCollections: &testItemCollections,
139 1 : ItemTables: &testItemTables,
140 1 : EnemyTables: &testEnemyTables,
141 1 : Layouts: &[]rawschema.Layout{
142 1 : {Id: "small_room", Tiles: testLayoutTiles, Start: "rect_rooms", Steps: []rawschema.EntityID{"fill_wall", "draw_rooms", "line_corridor", "doors", "isolated_walls"}},
143 1 : {Id: "big_room", Tiles: testLayoutTiles, Start: "full_room", Steps: []rawschema.EntityID{"fill_wall", "big_room", "isolated_walls"}},
144 1 : {Id: "cave", Tiles: testLayoutTiles, Start: "cave_noise", Steps: []rawschema.EntityID{"cave_automata", "cave_widen", "connect_rooms", "stalactites", "isolated_walls"}},
145 1 : {Id: "ruins", Tiles: testLayoutTiles, Start: "ruined_buildings", Steps: []rawschema.EntityID{"fill_wall", "ruined_walls", "debris", "ruined_paths", "isolated_walls"}},
146 1 : {Id: "forest", Tiles: rawschema.LayoutTiles{Floor: "ground", Wall: "wall", Void: "ground"}, Start: "forest_clearings", Steps: []rawschema.EntityID{"forest_floor", "forest_trees", "forest_trails", "forest_glades", "isolated_walls"}},
147 1 : {Id: "town_plaza", Tiles: testLayoutTiles, Start: "town_plaza"},
148 1 : {Id: "debug_town", Tiles: testLayoutTiles, Start: "debug_town"},
149 1 : },
150 1 : RectRoomStarts: &[]rawschema.RectRoomStart{{Id: "rect_rooms", Rooms: rawschema.RandInt{Base: 4, Spread: 10}, RoomSize: rawschema.RandInt{Base: 2, Spread: 8}}},
151 1 : SimpleStarts: &[]rawschema.SimpleStart{{Id: "full_room", Kind: rawschema.SimpleStartKindFullRoom}},
152 1 : NoiseStarts: &[]rawschema.NoiseStart{{Id: "cave_noise", WallChance: 0.3}},
153 1 : BuildingStarts: &[]rawschema.BuildingStart{{Id: "ruined_buildings", Buildings: rawschema.RandInt{Base: 3, Spread: 3}, BuildingWidth: rawschema.RandInt{Base: 8, Spread: 10}, BuildingHeight: rawschema.RandInt{Base: 6, Spread: 8}}},
154 1 : ClearingStarts: &[]rawschema.ClearingStart{{Id: "forest_clearings", Clearings: rawschema.RandInt{Base: 3, Spread: 4}, ClearingSize: rawschema.RandInt{Base: 4, Spread: 6}}},
155 1 : TemplateStarts: &[]rawschema.TemplateStart{{Id: "town_plaza", Template: "50x20_town_plaza"}, {Id: "debug_town", Template: "20x20_debug_town"}},
156 1 : SimpleSteps: &[]rawschema.SimpleStep{
157 1 : {Id: "fill_wall", Kind: rawschema.SimpleStepKindFillWall},
158 1 : {Id: "draw_rooms", Kind: rawschema.SimpleStepKindDrawRooms},
159 1 : {Id: "connect_rooms", Kind: rawschema.SimpleStepKindConnectRooms},
160 1 : {Id: "debris", Kind: rawschema.SimpleStepKindDebris},
161 1 : {Id: "forest_floor", Kind: rawschema.SimpleStepKindForestFloor},
162 1 : {Id: "isolated_walls", Kind: rawschema.SimpleStepKindIsolatedWalls},
163 1 : },
164 1 : CorridorSteps: &[]rawschema.CorridorStep{{Id: "line_corridor", Width: 3}},
165 1 : DoorSteps: &[]rawschema.DoorStep{{Id: "doors", Chance: 0.8}},
166 1 : BigRoomSteps: &[]rawschema.BigRoomStep{{Id: "big_room", PillarSpacing: rawschema.RandInt{Base: 3, Spread: 4}, ObstacleArea: 30, MazeGapChance: 0.3, PlatformRadius: rawschema.RandInt{Base: 2, Spread: 3}}},
167 1 : AutomataSteps: &[]rawschema.AutomataStep{{Id: "cave_automata", Iterations: 3, WallNeighbors: 6, MinRoomTiles: 10}},
168 1 : WidenSteps: &[]rawschema.WidenStep{{Id: "cave_widen", Chance: 0.3}},
169 1 : ScatterWallSteps: &[]rawschema.ScatterWallStep{{Id: "stalactites", Chance: 0.02}},
170 1 : RuinedWallSteps: &[]rawschema.RuinedWallStep{{Id: "ruined_walls", WallGapChance: 0.3, PartitionGapChance: 0.4}},
171 1 : RuinedPathSteps: &[]rawschema.RuinedPathStep{{Id: "ruined_paths", Chance: 0.3}},
172 1 : TreeSteps: &[]rawschema.TreeStep{{Id: "forest_trees", Density: 0.6, LargeTreeChance: 0.2}},
173 1 : TrailSteps: &[]rawschema.TrailStep{{Id: "forest_trails", Tile: "road"}},
174 1 : GladeSteps: &[]rawschema.GladeStep{{Id: "forest_glades", Spots: rawschema.RandInt{Base: 2, Spread: 4}}},
175 1 : }
176 : }
|