That shouldn't be too hard to write a function for. I'll have to wait until the weekend to make and test a function for that (I work full time during the week), but all it's really doing is changing the DB gender field of the owned adoptable table for the specific adopt.
Even if it needs 2 item functions (so one that makes it female and one that makes it male), it would work, if it's a bit much to code in to get the gender then swap to the other... I thought about looking into it myself too TBH by looking at how other items function factor. However I also fear messing it up xD
public function getGender($fetchMode = ""){
if($fetchMode == Model::GUI) return new Image("picuploads/{$this->gender}.png");
else return $this->gender;
}
Add this:
public function setGender($gender, $assignMode = ""){
if($assignMode == Model::UPDATE) $this->save("gender", $gender);
$this->gender = $gender;
}
Step 2. Go to model/domainmodel/itemfunction
At the top there is a long array list called
protected $validFunctions = [
at the end of that array inside the closing bracket add this ,"Gender"
Step 3. Add this function somewhere after all the other functions but before the save function (for neatness mainly)
Code:
protected function applyGender(OwnedItem $item, OwnedAdoptable $adopt){
$mysidia = Registry::get("mysidia");
$oldGender = $adopt->getGender();
if($oldGender == "f"){
$gender = "m";
$adopt->setGender($gender, "update");
}elseif($oldGender == "m"){
$gender = "f";
$adopt->setGender($gender, "update");
}else{
throw new ItemException("There is a problem with changing the gender of this adoptable.");
}
return "Your adoptable {$adopt->getName()} has had its gender successfully changed";
}
Step 4. Add the function in the item_functions table in the database like this:
Now all you have to do is create an item that uses Gender as the Gender item function and it should work. Here's my test: