6 Commits

Author SHA1 Message Date
541cdfeed3 add Attribute definition
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
Updates #2.
2023-07-23 14:18:29 -05:00
ffeece2598 ci: don't run unity-using pipeline stages in parallel
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-07-17 12:15:40 -05:00
5793bb04a3 set up license for every unity invocation
Some checks failed
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/tag/woodpecker Pipeline failed
2023-07-17 11:49:19 -05:00
3c31c751f2 set up license for every unity invocation 2023-07-17 11:45:09 -05:00
2a4f2449d7 chuck some logging into ci scripts
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-07-17 11:38:22 -05:00
3920414859 chuck some logging into ci scripts
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-07-17 11:33:43 -05:00
11 changed files with 169 additions and 23 deletions

View File

@@ -27,38 +27,41 @@ pipeline:
- chmod +x ${UNITY_DIR}/ci/before_script.sh - chmod +x ${UNITY_DIR}/ci/before_script.sh
- ${UNITY_DIR}/ci/before_script.sh - ${UNITY_DIR}/ci/before_script.sh
secrets: [unity_license] secrets: [unity_license]
# test-playmode: test-playmode:
# image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION} image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION}
# group: test commands:
# commands: - ${UNITY_DIR}/ci/before_script.sh
# - chmod +x ${UNITY_DIR}/ci/test.sh - chmod +x ${UNITY_DIR}/ci/test.sh
# - ${UNITY_DIR}/ci/test.sh - ${UNITY_DIR}/ci/test.sh
# environment: environment:
# - TEST_PLATFORM=playmode - TEST_PLATFORM=playmode
# - TESTING_TYPE=NUNIT - TESTING_TYPE=NUNIT
# - VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER} - VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}
# - VERSION_BUILD_VAR=${CI_COMMIT_HASH} - VERSION_BUILD_VAR=${CI_COMMIT_HASH}
# test-editmode: secrets: [unity_license]
# image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION} test-editmode:
# group: test image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION}
# commands: commands:
# - chmod +x ${UNITY_DIR}/ci/test.sh - ${UNITY_DIR}/ci/before_script.sh
# - ${UNITY_DIR}/ci/test.sh - chmod +x ${UNITY_DIR}/ci/test.sh
# environment: - ${UNITY_DIR}/ci/test.sh
# - TEST_PLATFORM=editmode environment:
# - TESTING_TYPE=NUNIT - TEST_PLATFORM=editmode
# - VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER} - TESTING_TYPE=NUNIT
# - VERSION_BUILD_VAR=${CI_COMMIT_HASH} - VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}
- VERSION_BUILD_VAR=${CI_COMMIT_HASH}
secrets: [unity_license]
build-standalone-windows: build-standalone-windows:
image: ${IMAGE}:${UNITY_VERSION}-windows-mono-${IMAGE_VERSION} image: ${IMAGE}:${UNITY_VERSION}-windows-mono-${IMAGE_VERSION}
group: build
commands: commands:
- ${UNITY_DIR}/ci/before_script.sh
- chmod +x ./ci/build.sh - chmod +x ./ci/build.sh
- ./ci/build.sh - ./ci/build.sh
environment: environment:
- BUILD_TARGET=StandaloneWindows64 - BUILD_TARGET=StandaloneWindows64
- VERSION_NUMBER_VAR=${CI_COMMIT_TAG} - VERSION_NUMBER_VAR=${CI_COMMIT_TAG}
- VERSION_BUILD_VAR=${CI_COMMIT_HASH} - VERSION_BUILD_VAR=${CI_COMMIT_HASH}
secrets: [unity_license]
when: when:
event: tag event: tag
package: package:

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public struct Attribute
{
[SerializeField]
private long _base;
public Attribute(long stat)
{
_base = stat;
}
/// <summary>
/// Permanently increase the stat value.
/// </summary>
/// <param name="by">Increase amount.</param>
public void LevelUp(long by)
{
_base += by;
}
/// <summary>
/// Calculates the stat value with accumulated buff and debuff modifiers.
/// </summary>
/// <param name="baseBonus">Additive bonus applied before multiplicative scaling.</param>
/// <param name="permyriadBonus">Multiplicative scaling in hundredths of a percent. E.g., 625 permyriad corresponds to 6.25%.</param>
/// <param name="flatBonus">Additive bonus applied after multiplicative scaling.</param>
/// <returns>(base + baseBonus) * (100% + permyriadBonus) + flatBonus, bounded below by 0.</returns>
public long Calc(long baseBonus, long permyriadBonus, long flatBonus)
{
var r = _base + baseBonus;
var m = permyriadBonus + 10000;
r = r * (m / 10000) + (r / 10000) * (m % 10000) + flatBonus;
if (r <= 0)
{
return 0;
}
return r;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7d084c6ff925d3448dad326e9980f08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
{
"name": "IdleSurvivors"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e5250715ffed2b644bacb4c76ae6a775
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Tests.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9048b33fed80c814dbfdb2713db19d6d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class AttributeTest
{
[Test]
[TestCase(1000000, 0, 0, 0, 0, ExpectedResult = 1000000)]
[TestCase(1000000, 1, 0, 0, 0, ExpectedResult = 1000001)]
[TestCase(1000000, 0, 2, 0, 0, ExpectedResult = 1000002)]
[TestCase(1000000, 0, 0, 10000, 0, ExpectedResult = 2000000)]
[TestCase(1000000, 0, 0, 0, 3, ExpectedResult = 1000003)]
[TestCase(0, 1000000, 1000000, 5000, 1000, ExpectedResult = 3001000)]
[TestCase(1000000, 0, 0, -10000, 0, ExpectedResult = 0)]
[TestCase(1000000, 0, 0, -20000, 0, ExpectedResult = 0)]
[TestCase(1000000, 0, 0, -20000, 50, ExpectedResult = 0)]
public long Calc(long startStat, long levelUp, long baseBonus, long permyriadBonus, long flatBonus)
{
var attr = new Attribute(startStat);
attr.LevelUp(levelUp);
return attr.Calc(baseBonus, permyriadBonus, flatBonus);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4d405f62d1e7dc4aaf451051bf27d73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

24
Assets/Tests/Tests.asmdef Normal file
View File

@@ -0,0 +1,24 @@
{
"name": "Tests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"IdleSurvivors"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0e24b24d5798c7c4b979b314b1a7afce
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,5 @@
{
"m_Dictionary": {
"m_DictionaryValues": []
}
}