Skip to content

Commit c68ef3f

Browse files
authored
Merge pull request #9 from admon84/development
Reorganizing
2 parents 26f8799 + 9426388 commit c68ef3f

21 files changed

+2286
-16163
lines changed

.eslintignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
# Folders
2-
/node_modules
3-
/docs
4-
/dist
5-
/coverage
6-
/server
7-
8-
# File types
9-
**/*.json
10-
**/*.md
11-
**/*.yml
1+
dist/

.eslintrc.json

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,15 @@
11
{
2-
"env": {
3-
"browser": false,
4-
"es2021": true,
5-
"screeps/screeps": true,
6-
"jest": true
7-
},
8-
"extends": [
9-
"airbnb-base",
10-
"plugin:import/typescript",
11-
"plugin:prettier/recommended",
12-
// "plugin:jsdoc/recommended",
13-
"plugin:jest/recommended",
14-
"plugin:@typescript-eslint/recommended"
15-
],
162
"parser": "@typescript-eslint/parser",
17-
"parserOptions": {
18-
"ecmaVersion": 12,
19-
"sourceType": "module"
20-
},
21-
"plugins": [
22-
"@typescript-eslint",
23-
"screeps",
24-
"import",
25-
"prettier",
26-
"jsdoc",
27-
"jest"
3+
"plugins": ["@typescript-eslint", "prettier"],
4+
"extends": [
5+
"eslint:recommended",
6+
"plugin:@typescript-eslint/recommended",
7+
"prettier"
288
],
299
"rules": {
30-
"@typescript-eslint/no-empty-interface": 0,
31-
"no-shadow": "off",
32-
"@typescript-eslint/no-shadow": ["error"],
33-
"default-case": ["error", { "commentPattern": "^skip\\sdefault" }],
34-
"no-param-reassign": 0,
35-
"no-underscore-dangle": 0,
36-
"no-unused-vars": 0,
37-
"no-console": 0,
38-
"prefer-spread": 0,
39-
"import/no-cycle": 0,
40-
"import/extensions": [
41-
"error",
42-
"ignorePackages",
43-
{
44-
"js": "never",
45-
"mjs": "never",
46-
"jsx": "never",
47-
"ts": "never",
48-
"tsx": "never"
49-
}
50-
],
51-
"prettier/prettier": "error",
52-
"arrow-body-style": "off",
53-
"prefer-arrow-callback": "off"
54-
},
55-
"settings": {
10+
"prettier/prettier": "warn",
11+
"@typescript-eslint/no-unused-vars": "warn",
12+
"@typescript-eslint/no-namespace": "off",
13+
"@typescript-eslint/no-explicit-any": "warn"
5614
}
57-
}
15+
}

.gitconsensus.yaml

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
node_modules
1+
node_modules/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.prettierrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"editor.formatOnSave": true,
3-
"semi": false,
42
"tabWidth": 4,
3+
"semi": true,
54
"printWidth": 100,
65
"singleQuote": true,
7-
"trailingComma": "all",
8-
"arrowParens": "avoid",
6+
"trailingComma": "es5",
97
"endOfLine": "auto"
108
}

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
# Simple Allies
2-
Allows for simple communication between allies using a public segment
32

4-
## Usage
3+
Simple Allies is a tool for Screeps that simplifies ally communication. It provides a data model for segment communication, facilitating requests for resources, defense, attacks, hostility, work, funneling, and scouting. This is designed to enhance alliance cooperation and strategic gameplay.
54

6-
Plug this into your screeps bot and begin communicating with allies!
5+
### Usage
76

8-
- priority values should be from 0-1, where 1 is most preferred and 0 is least preferred
9-
- avoid sending verbose data! The more data you send, the more expensive it is for your allies to parse and read it.
7+
To integrate Simple Allies into your Screeps bot, import the necessary components from the project and incorporate them into your code.
8+
9+
### Code
10+
11+
For more details, refer to the source code:
12+
13+
- TypeScript source code: [src/](./src/)
14+
- Built JavaScript code: [dist/](./dist/)
15+
16+
Please note that the JavaScript code is generated from the TypeScript source code and should be functionally identical.
17+
18+
### Contributing
19+
20+
Contributions are welcome! Feel free to submit a pull request.

dist/exampleBot.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', { value: true });
4+
5+
var simpleAllies = require('./simpleAllies.js');
6+
7+
/**
8+
* Example bot loop
9+
*/
10+
function loop() {
11+
// Read next an ally segment
12+
simpleAllies.simpleAllies.initRun();
13+
// Respond to ally requests
14+
respondToAllyDefenseRequests();
15+
respondToAllyResourceRequests();
16+
// Request support from allies
17+
requestAllyResources();
18+
requestAllyDefense();
19+
// Update ally segment
20+
simpleAllies.simpleAllies.endRun();
21+
}
22+
/**
23+
* Example of responding to ally defense requests
24+
*/
25+
function respondToAllyDefenseRequests() {
26+
if (!simpleAllies.simpleAllies.allySegmentData)
27+
return;
28+
// Send creeps to defend rooms
29+
for (const request of simpleAllies.simpleAllies.allySegmentData.requests.defense) {
30+
console.log('[simpleAllies] Respond to defense request', JSON.stringify(request));
31+
// ...
32+
}
33+
}
34+
/**
35+
* Example of responding to ally resource requests
36+
*/
37+
function respondToAllyResourceRequests() {
38+
if (!simpleAllies.simpleAllies.allySegmentData)
39+
return;
40+
// Send resources to rooms
41+
for (const request of simpleAllies.simpleAllies.allySegmentData.requests.resource) {
42+
console.log('[simpleAllies] Respond to resource request', JSON.stringify(request));
43+
// ...
44+
}
45+
}
46+
/**
47+
* Example of requesting ally resources
48+
*/
49+
function requestAllyResources() {
50+
// Add resource request
51+
simpleAllies.simpleAllies.requestResource({
52+
priority: 1,
53+
roomName: 'W1N1',
54+
resourceType: RESOURCE_ENERGY,
55+
amount: 1000,
56+
});
57+
}
58+
/**
59+
* Example of requesting ally defense
60+
*/
61+
function requestAllyDefense() {
62+
// Add defense request
63+
simpleAllies.simpleAllies.requestDefense({
64+
priority: 1,
65+
roomName: 'W1N1',
66+
});
67+
}
68+
69+
exports.loop = loop;

0 commit comments

Comments
 (0)