8 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
06ccf153c9 remove test stages from CI while we have no tests
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2023-07-16 23:57:06 -05:00
65b6e17862 add Code Coverage package
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-07-16 23:55:36 -05:00
16 changed files with 194 additions and 9 deletions

View File

@@ -29,8 +29,8 @@ pipeline:
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:
@@ -38,13 +38,11 @@ pipeline:
- 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}
when: secrets: [unity_license]
branch:
exclude: [main]
test-editmode: test-editmode:
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:
@@ -52,19 +50,18 @@ pipeline:
- 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}
when: secrets: [unity_license]
branch:
exclude: [main]
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:

8
Assets/Scripts.meta Normal file
View File

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

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,8 @@
fileFormatVersion: 2
guid: a298ceea9d6a15144a14410c55bc73f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3fad0d600a90224d8b11fa8ab794a5f
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

@@ -6,6 +6,7 @@
"com.unity.ide.vscode": "1.2.5", "com.unity.ide.vscode": "1.2.5",
"com.unity.render-pipelines.universal": "14.0.8", "com.unity.render-pipelines.universal": "14.0.8",
"com.unity.test-framework": "1.1.33", "com.unity.test-framework": "1.1.33",
"com.unity.testtools.codecoverage": "1.2.4",
"com.unity.textmeshpro": "3.0.6", "com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.4", "com.unity.timeline": "1.7.4",
"com.unity.ugui": "1.0.0", "com.unity.ugui": "1.0.0",

View File

@@ -84,6 +84,13 @@
"dependencies": {}, "dependencies": {},
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.settings-manager": {
"version": "2.0.1",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": { "com.unity.shadergraph": {
"version": "14.0.8", "version": "14.0.8",
"depth": 1, "depth": 1,
@@ -104,6 +111,16 @@
}, },
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.testtools.codecoverage": {
"version": "1.2.4",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.0.16",
"com.unity.settings-manager": "1.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": { "com.unity.textmeshpro": {
"version": "3.0.6", "version": "3.0.6",
"depth": 0, "depth": 0,

View File

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