Jelajahi Sumber

fix main quest attribute was not parsed

Kolja Strohm 16 jam lalu
induk
melakukan
f923260379
2 mengubah file dengan 118 tambahan dan 6 penghapusan
  1. 10 3
      FactoryCraft/Quest.cpp
  2. 108 3
      Windows Version/data/quests/quests.json

+ 10 - 3
FactoryCraft/Quest.cpp

@@ -481,6 +481,8 @@ Quest* QuestType::fromJson(Framework::JSON::JSONObject* zJson) const
             = Framework::Text("itemType:")
             + Game::INSTANCE->zItemType(ItemTypeEnum::PLAYER_HAND)->getName();
     }
+    result->mainQuest
+        = zJson->asObject()->zValue("mainQuest")->asBool()->getBool();
     return result;
 }
 
@@ -547,6 +549,8 @@ Framework::JSON::JSONObject* QuestType::toJsonObject(Quest* zObject) const
         result->addValue(
             "imagePath", new Framework::JSON::JSONString(zObject->imagePath));
     }
+    result->addValue(
+        "mainQuest", new Framework::JSON::JSONBool(zObject->mainQuest));
     return result;
 }
 
@@ -580,7 +584,10 @@ JSONObjectValidationBuilder* QuestType::addToValidator(
             Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
                 ItemTypeNameFactory::TYPE_ID),
             0,
-            1);
+            1)
+        ->withRequiredBool("mainQuest")
+        ->withDefault(false)
+        ->finishBool();
 }
 
 QuestCollection::QuestCollection()
@@ -601,10 +608,10 @@ void QuestCollection::processEvent(QuestEvent* zEvent, QuestParty* zParty)
 
 bool QuestCollection::isVisible(QuestParty* zParty, QuestManager* zManager)
 {
-    bool visible = 1;
+    bool visible = 0;
     for (Quest* quest : quests)
     {
-        visible &= quest->isVisible(zParty, zManager);
+        visible |= quest->isVisible(zParty, zManager);
     }
     return visible;
 }

+ 108 - 3
Windows Version/data/quests/quests.json

@@ -76,10 +76,10 @@
                 "requirements": [
                     {
                         "type": "item_in_inventory",
-                        "amount": 10,
+                        "amount": 4,
                         "itemType": "Wooden Stick",
                         "id": "wooden_sticks_requirement",
-                        "description": "Wooden Sticks"
+                        "description": "Wooden Stick"
                     }
                 ],
                 "rewards": [
@@ -91,7 +91,112 @@
                                 "item": {
                                     "type": "Flint"
                                 },
-                                "count": 10
+                                "count": 1
+                            }
+                        ]
+                    }
+                ]
+            },
+            {
+                "questId": "stone",
+                "questName": "Stone",
+                "description": "You can get some stones by searching throu gravel.",
+                "imagePath": "itemType:Gravel",
+                "requirements": [
+                    {
+                        "type": "item_in_inventory",
+                        "amount": 4,
+                        "itemType": "Stone",
+                        "id": "stone_requirement",
+                        "description": "Stone"
+                    }
+                ],
+                "rewards": [
+                    {
+                        "rewardId": "1",
+                        "type": "give_items",
+                        "items": [
+                            {
+                                "item": {
+                                    "type": "Flint"
+                                },
+                                "count": 1
+                            }
+                        ]
+                    }
+                ]
+            },
+            {
+                "questId": "tree_bark",
+                "questName": "Tree bark",
+                "description": "Just grab some bark from the Trees arround you.",
+                "imagePath": "itemType:Tree bark",
+                "requirements": [
+                    {
+                        "type": "item_in_inventory",
+                        "amount": 1,
+                        "itemType": "Tree bark",
+                        "id": "tree_bark_requirement",
+                        "description": "Tree bark"
+                    }
+                ],
+                "rewards": [
+                    {
+                        "rewardId": "1",
+                        "type": "give_items",
+                        "items": [
+                            {
+                                "item": {
+                                    "type": "Flint"
+                                },
+                                "count": 1
+                            }
+                        ]
+                    }
+                ]
+            },
+            {
+                "questId": "campfire",
+                "questName": "Campfire",
+                "description": "Use the gathered materials to craft a campfire.\n\nYou will need a fast burning material like tree bark to start the burning process.\nOnce the fire burns it only requires burnable materials like wooden sticks to keep it burning.",
+                "imagePath": "itemType:Campfire",
+                "requiredQuestIds": [
+                    [
+                        "tree_bark"
+                    ],
+                    [
+                        "stone"
+                    ],
+                    [
+                        "wood_sticks"
+                    ]
+                ],
+                "mainQuest": true,
+                "requirements": [
+                    {
+                        "type": "item_in_inventory",
+                        "amount": 1,
+                        "itemType": "Campfire",
+                        "id": "campfire_requirement",
+                        "description": "Campfire"
+                    }
+                ],
+                "rewards": [
+                    {
+                        "rewardId": "1",
+                        "type": "give_items",
+                        "items": [
+                            {
+                                "item": {
+                                    "type": "Tree bark"
+                                },
+                                "count": 1
+                            },
+                            {
+                                "item": {
+                                    "type": "Wooden Stick"
+                                },
+                                "count": 5
                             }
                         ]
                     }