Skip to content

Commit

Permalink
If you leave items at merchants, they will take them back if there is…
Browse files Browse the repository at this point in the history
… space
  • Loading branch information
Pyrdacor committed Jun 11, 2022
1 parent 6731bf0 commit d1de113
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
27 changes: 26 additions & 1 deletion Ambermoon.Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11684,7 +11684,32 @@ void Exit()

if (boughtItems.Any(item => item != null && !item.Empty))
{
layout.OpenYesNoPopup(ProcessText(DataNameProvider.WantToGoWithoutItemsMerchant), Exit, ClosePopup, ClosePopup, 2);
void ExitAndReturnItems()
{
var merchantSlots = merchant.Slots.ToList();

foreach (var items in boughtItems)
ReturnItems(items);

void ReturnItems(ItemSlot items)
{
var slot = merchantSlots.FirstOrDefault(s => s.ItemIndex == items.ItemIndex) ??
merchantSlots.FirstOrDefault(s => s.ItemIndex == 0 || s.Amount == 0);

if (slot != null)
{
if (slot.ItemIndex == 0)
slot.Amount = 0;

slot.ItemIndex = items.ItemIndex;
slot.Amount += items.Amount;
}
}

Exit();
}

layout.OpenYesNoPopup(ProcessText(DataNameProvider.WantToGoWithoutItemsMerchant), ExitAndReturnItems, ClosePopup, ClosePopup, 2);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Ambermoon.net/Ambermoon.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Ambermoon</RootNamespace>
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;linux-arm64;osx-x64;osx.12-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<Version>1.6.5</Version>
<Copyright>Copyright (C) 2020-2021 by Robert Schneckenhaus</Copyright>
<Company>Robert Schneckenhaus</Company>
Expand Down
8 changes: 8 additions & 0 deletions Ambermoon.net/Mac/Ambermoon.net.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
<dict>
<key>CFBundleExecutable</key>
<string>Ambermoon.net</string>
<key>CFBundleDisplayName</key>
<string>Ambermoon.net</string>
<key>CFBundleName</key>
<string>Ambermoon.net</string>
<key>CFBundleVersion</key>
<string>1.6.5</string>
<key>CFBundleIconFile</key>
<string>Ambermoon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.pyrdacor.ambermoon.net</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if ($isWindows) {
} else {
Write-Host Publish Mac executable
dotnet publish -c Release "./Ambermoon.net/Ambermoon.net.csproj" -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -r osx-x64 --no-restore --self-contained
dotnet publish -c Release "./Ambermoon.net/Ambermoon.net.csproj" -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -r osx.12-arm64 --no-restore --self-contained
dotnet publish -c Release "./Ambermoon.net/Ambermoon.net.csproj" -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -r osx-arm64 --no-restore --self-contained
dotnet publish -c Release "./Ambermoon.ConcatFiles/Ambermoon.ConcatFiles.csproj" -r osx-x64 --no-restore
Write-Host Pack zips for Mac
Start-Process -FilePath "./Ambermoon.ConcatFiles/bin/Any CPU/Release/netcoreapp3.1/osx-x64/publish/Ambermoon.ConcatFiles" -Wait -WorkingDirectory . -ArgumentList '"./versions.dat"','"./Ambermoon.net/bin/Any CPU/Release/net6.0/osx-x64/publish/Ambermoon.net"'
Expand All @@ -32,7 +32,7 @@ if ($isWindows) {
cp "./Ambermoon.net/bin/Any CPU/Release/net6.0/osx-x64/publish/Ambermoon.net" ./bundle/Ambermoon.net/Ambermoon.net.app/Contents/MacOS/
cp -r ./Package/* ./bundle/Ambermoon.net/Ambermoon.net.app/Contents/MacOS/
7z a Ambermoon.net-Mac.zip ./bundle/Ambermoon.net/ -mx9
Start-Process -FilePath "./Ambermoon.ConcatFiles/bin/Any CPU/Release/netcoreapp3.1/osx-x64/publish/Ambermoon.ConcatFiles" -Wait -WorkingDirectory . -ArgumentList '"./versions.dat"','"./Ambermoon.net/bin/Any CPU/Release/net6.0/osx.12-arm64/publish/Ambermoon.net"'
cp "./Ambermoon.net/bin/Any CPU/Release/net6.0/osx.12-arm64/publish/Ambermoon.net" ./bundle/Ambermoon.net/Ambermoon.net.app/Contents/MacOS/
Start-Process -FilePath "./Ambermoon.ConcatFiles/bin/Any CPU/Release/netcoreapp3.1/osx-x64/publish/Ambermoon.ConcatFiles" -Wait -WorkingDirectory . -ArgumentList '"./versions.dat"','"./Ambermoon.net/bin/Any CPU/Release/net6.0/osx-arm64/publish/Ambermoon.net"'
cp "./Ambermoon.net/bin/Any CPU/Release/net6.0/osx-arm64/publish/Ambermoon.net" ./bundle/Ambermoon.net/Ambermoon.net.app/Contents/MacOS/
7z a Ambermoon.net-Mac-ARM.zip ./bundle/Ambermoon.net/ -mx9
}

0 comments on commit d1de113

Please sign in to comment.