Compare commits
8 Commits
v23.07.16
...
541cdfeed3
Author | SHA1 | Date | |
---|---|---|---|
541cdfeed3 | |||
ffeece2598 | |||
5793bb04a3 | |||
3c31c751f2 | |||
2a4f2449d7 | |||
3920414859 | |||
06ccf153c9 | |||
65b6e17862 |
@@ -29,8 +29,8 @@ pipeline:
|
||||
secrets: [unity_license]
|
||||
test-playmode:
|
||||
image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION}
|
||||
group: test
|
||||
commands:
|
||||
- ${UNITY_DIR}/ci/before_script.sh
|
||||
- chmod +x ${UNITY_DIR}/ci/test.sh
|
||||
- ${UNITY_DIR}/ci/test.sh
|
||||
environment:
|
||||
@@ -38,13 +38,11 @@ pipeline:
|
||||
- TESTING_TYPE=NUNIT
|
||||
- VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}
|
||||
- VERSION_BUILD_VAR=${CI_COMMIT_HASH}
|
||||
when:
|
||||
branch:
|
||||
exclude: [main]
|
||||
secrets: [unity_license]
|
||||
test-editmode:
|
||||
image: ${IMAGE}:${UNITY_VERSION}-base-${IMAGE_VERSION}
|
||||
group: test
|
||||
commands:
|
||||
- ${UNITY_DIR}/ci/before_script.sh
|
||||
- chmod +x ${UNITY_DIR}/ci/test.sh
|
||||
- ${UNITY_DIR}/ci/test.sh
|
||||
environment:
|
||||
@@ -52,19 +50,18 @@ pipeline:
|
||||
- TESTING_TYPE=NUNIT
|
||||
- VERSION_NUMBER_VAR=${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}
|
||||
- VERSION_BUILD_VAR=${CI_COMMIT_HASH}
|
||||
when:
|
||||
branch:
|
||||
exclude: [main]
|
||||
secrets: [unity_license]
|
||||
build-standalone-windows:
|
||||
image: ${IMAGE}:${UNITY_VERSION}-windows-mono-${IMAGE_VERSION}
|
||||
group: build
|
||||
commands:
|
||||
- ${UNITY_DIR}/ci/before_script.sh
|
||||
- chmod +x ./ci/build.sh
|
||||
- ./ci/build.sh
|
||||
environment:
|
||||
- BUILD_TARGET=StandaloneWindows64
|
||||
- VERSION_NUMBER_VAR=${CI_COMMIT_TAG}
|
||||
- VERSION_BUILD_VAR=${CI_COMMIT_HASH}
|
||||
secrets: [unity_license]
|
||||
when:
|
||||
event: tag
|
||||
package:
|
||||
|
8
Assets/Scripts.meta
Normal file
8
Assets/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa9282cec7ff5ee4ea9898bfc5d2366d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
42
Assets/Scripts/Attribute.cs
Normal file
42
Assets/Scripts/Attribute.cs
Normal 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;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Attribute.cs.meta
Normal file
11
Assets/Scripts/Attribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7d084c6ff925d3448dad326e9980f08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Editor.meta
Normal file
8
Assets/Scripts/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a298ceea9d6a15144a14410c55bc73f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/Scripts/Editor/BuildCommand.cs.meta
Normal file
11
Assets/Scripts/Editor/BuildCommand.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3fad0d600a90224d8b11fa8ab794a5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/Scripts/IdleSurvivors.asmdef
Normal file
3
Assets/Scripts/IdleSurvivors.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "IdleSurvivors"
|
||||
}
|
7
Assets/Scripts/IdleSurvivors.asmdef.meta
Normal file
7
Assets/Scripts/IdleSurvivors.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5250715ffed2b644bacb4c76ae6a775
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Tests.meta
Normal file
8
Assets/Tests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9048b33fed80c814dbfdb2713db19d6d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Tests/AttributeTest.cs
Normal file
25
Assets/Tests/AttributeTest.cs
Normal 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);
|
||||
}
|
||||
}
|
11
Assets/Tests/AttributeTest.cs.meta
Normal file
11
Assets/Tests/AttributeTest.cs.meta
Normal 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
24
Assets/Tests/Tests.asmdef
Normal 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
|
||||
}
|
7
Assets/Tests/Tests.asmdef.meta
Normal file
7
Assets/Tests/Tests.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e24b24d5798c7c4b979b314b1a7afce
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -6,6 +6,7 @@
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.render-pipelines.universal": "14.0.8",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.testtools.codecoverage": "1.2.4",
|
||||
"com.unity.textmeshpro": "3.0.6",
|
||||
"com.unity.timeline": "1.7.4",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
|
@@ -84,6 +84,13 @@
|
||||
"dependencies": {},
|
||||
"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": {
|
||||
"version": "14.0.8",
|
||||
"depth": 1,
|
||||
@@ -104,6 +111,16 @@
|
||||
},
|
||||
"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": {
|
||||
"version": "3.0.6",
|
||||
"depth": 0,
|
||||
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"m_Dictionary": {
|
||||
"m_DictionaryValues": []
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user