Răsfoiți Sursa

Implement CArtHandler::isBigArtifact and CArtifact::isTradable

ArseniyShestakov 10 ani în urmă
părinte
comite
de6752c048
2 a modificat fișierele cu 15 adăugiri și 0 ștergeri
  1. 13 0
      lib/CArtHandler.cpp
  2. 2 0
      lib/CArtHandler.h

+ 13 - 0
lib/CArtHandler.cpp

@@ -64,6 +64,11 @@ bool CArtifact::isBig () const
 	return VLC->arth->isBigArtifact(id);
 }
 
+bool CArtifact::isTradable () const
+{
+	return VLC->arth->isTradableArtifact(id);
+}
+
 CArtifact::CArtifact()
 {
 	setNodeType(ARTIFACT);
@@ -578,6 +583,14 @@ bool CArtHandler::legalArtifact(ArtifactID id)
 			!(art->constituents); //no combo artifacts spawning
 }
 
+bool CArtHandler::isTradableArtifact(ArtifactID id) const
+{
+	if (id < 7 && id != ArtifactID::SPELL_SCROLL)
+		return false;
+
+	return true;
+}
+
 void CArtHandler::initAllowedArtifactsList(const std::vector<bool> &allowed)
 {
 	allowedArtifacts.clear();

+ 2 - 0
lib/CArtHandler.h

@@ -59,6 +59,7 @@ public:
 	const std::string &EventText() const;
 
 	bool isBig () const;
+	bool isTradable () const;
 
 	int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
 	std::string nodeName() const override;
@@ -215,6 +216,7 @@ public:
 	//void getAllowedArts(std::vector<ConstTransitivePtr<CArtifact> > &out, std::vector<CArtifact*> *arts, int flag);
 	//void getAllowed(std::vector<ConstTransitivePtr<CArtifact> > &out, int flags);
 	bool isBigArtifact (ArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
+	bool isTradableArtifact (ArtifactID id) const;
 	void initAllowedArtifactsList(const std::vector<bool> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
 	static ArtifactID creatureToMachineID(CreatureID id);
 	static CreatureID machineIDToCreature(ArtifactID id);