Skip to content

Commit 064e1ee

Browse files
feat(TeamTransfer): policy team transfer system
1 parent 1069815 commit 064e1ee

42 files changed

Lines changed: 3212 additions & 514 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.luarc.json

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,41 @@
1313
},
1414
"workspace": {
1515
"library": [
16-
"recoil-lua-library"
16+
"recoil-lua-library",
17+
"luarules/",
18+
"luaui/"
19+
],
20+
"userThirdParty": [
21+
"types"
1722
],
1823
"ignoreDir": [
1924
".vscode",
2025
"luaui/Tests",
2126
"luaui/TestsExamples"
22-
]
27+
],
28+
"checkThirdParty": false
29+
},
30+
"diagnostics": {
31+
"globals": [
32+
"VFS",
33+
"Spring",
34+
"Game",
35+
"CMD",
36+
"gadget",
37+
"widget",
38+
"GG",
39+
"WG",
40+
"gadgetHandler",
41+
"widgetHandler"
42+
],
43+
"type": {
44+
"definition": [
45+
"luaui/types/"
46+
]
47+
},
48+
"workspaceDelay": 0
49+
},
50+
"semantic": {
51+
"enable": true
2352
}
2453
}

README_test_runner.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# BAR Standalone Test Runner
2+
3+
A command-line test runner for BAR's unit tests that can execute tests without starting the game or Spring engine.
4+
5+
## Installation
6+
7+
Ensure you have Lua 5.1 installed:
8+
```bash
9+
sudo apt install lua5.1
10+
```
11+
12+
## Usage
13+
14+
Run the test runner from the BAR repository root directory:
15+
16+
```bash
17+
# Run all unit tests
18+
lua5.1 test_runner.lua
19+
20+
# Run all unit tests (explicit pattern)
21+
lua5.1 test_runner.lua unit/
22+
23+
# Run specific test file
24+
lua5.1 test_runner.lua unit/test_policy_builder
25+
lua5.1 test_runner.lua unit/test_predicates
26+
lua5.1 test_runner.lua unit/test_resource_tax_calculations
27+
lua5.1 test_runner.lua unit/test_unit_sharing_logic
28+
lua5.1 test_runner.lua test_ally_assist
29+
30+
# Run tests matching a pattern
31+
lua5.1 test_runner.lua predicates
32+
lua5.1 test_runner.lua policy
33+
```
34+
35+
## Features
36+
37+
- **Standalone Execution**: No need to start BAR or Spring engine
38+
- **Fast Feedback**: Quick test execution for tight development loops
39+
- **Colored Output**: Green for pass, red for fail, magenta for errors
40+
- **Timing Information**: Shows execution time for each test
41+
- **Pattern Matching**: Run specific tests or test groups
42+
- **Exit Codes**: Returns 0 for success, 1 for failures (CI-friendly)
43+
44+
## Test Structure
45+
46+
Unit tests are located in `luaui/Tests/team_transfer/unit/` and follow this structure:
47+
48+
```lua
49+
function setup()
50+
-- Test setup code (mocking, initialization)
51+
end
52+
53+
function cleanup()
54+
-- Test cleanup code
55+
end
56+
57+
function test()
58+
-- Test assertions and logic
59+
end
60+
```
61+
62+
## Mocking
63+
64+
The test runner provides mocking capabilities through BAR's testing utilities:
65+
66+
- `Test.mock(parent, target, fn)` - Mock a function
67+
- `Test.spy(parent, target)` - Spy on function calls
68+
- `VFS.Include(path)` - Mock VFS system for loading modules
69+
70+
## Output Example
71+
72+
```
73+
BAR Standalone Test Runner
74+
==========================
75+
PASS: test_policy_builder.lua [2 ms]
76+
PASS: test_predicates.lua [1 ms]
77+
PASS: test_resource_tax_calculations.lua [3 ms]
78+
PASS: test_unit_sharing_logic.lua [2 ms]
79+
PASS: test_ally_assist.lua [1 ms]
80+
81+
Results: 6/6 tests passed
82+
All tests passed! ✓
83+
```
84+
85+
## Integration with CI
86+
87+
The test runner returns appropriate exit codes for CI integration:
88+
- Exit code 0: All tests passed
89+
- Exit code 1: One or more tests failed
90+
91+
## Troubleshooting
92+
93+
### "lua: command not found"
94+
Install Lua 5.1: `sudo apt install lua5.1`
95+
96+
### "Could not open file"
97+
Ensure you're running the command from the BAR repository root directory.
98+
99+
### Test failures
100+
Check the error messages in the output. Common issues:
101+
- Missing mock setup in test files
102+
- Incorrect assertions
103+
- Missing dependencies in test environment

gamedata/sharingoptions.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"max": 0
3131
}
3232
},
33-
"disable_assist_ally_construction": {
34-
"value": true,
33+
"game_assist_ally": {
34+
"value": "disabled",
3535
"locked": true
3636
}
3737
}
@@ -67,8 +67,8 @@
6767
"step": 10
6868
}
6969
},
70-
"disable_assist_ally_construction": {
71-
"value": true,
70+
"game_assist_ally": {
71+
"value": "disabled",
7272
"locked": true
7373
}
7474
}
@@ -99,8 +99,8 @@
9999
"locked": true,
100100
"ui": "hidden"
101101
},
102-
"disable_assist_ally_construction": {
103-
"value": false,
102+
"game_assist_ally": {
103+
"value": "enabled",
104104
"locked": true
105105
}
106106
}
@@ -112,7 +112,10 @@
112112
"allowRanked": false,
113113
"options": {
114114
"unit_sharing_mode": {
115-
"locked": false
115+
"locked": false,
116+
"bounds": {
117+
"items": ["enabled", "t2cons", "combat", "combat_t2cons", "disabled"]
118+
}
116119
},
117120
"tax_resource_sharing_amount": {
118121
"locked": false
@@ -121,7 +124,7 @@
121124
"value": 0,
122125
"locked": false
123126
},
124-
"disable_assist_ally_construction": {
127+
"game_assist_ally": {
125128
"locked": false
126129
}
127130
}

luarules/gadgets/game_disable_assist_ally.lua

Lines changed: 0 additions & 81 deletions
This file was deleted.

luarules/gadgets/game_no_share_to_enemy.lua

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)