Skip to content

Commit

Permalink
Reorganizing
Browse files Browse the repository at this point in the history
  • Loading branch information
admon84 committed Dec 31, 2023
1 parent 26f8799 commit 9426388
Show file tree
Hide file tree
Showing 21 changed files with 2,286 additions and 16,163 deletions.
12 changes: 1 addition & 11 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# Folders
/node_modules
/docs
/dist
/coverage
/server

# File types
**/*.json
**/*.md
**/*.yml
dist/
62 changes: 10 additions & 52 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,15 @@
{
"env": {
"browser": false,
"es2021": true,
"screeps/screeps": true,
"jest": true
},
"extends": [
"airbnb-base",
"plugin:import/typescript",
"plugin:prettier/recommended",
// "plugin:jsdoc/recommended",
"plugin:jest/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"screeps",
"import",
"prettier",
"jsdoc",
"jest"
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-empty-interface": 0,
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"default-case": ["error", { "commentPattern": "^skip\\sdefault" }],
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"no-unused-vars": 0,
"no-console": 0,
"prefer-spread": 0,
"import/no-cycle": 0,
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"mjs": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"prettier/prettier": "error",
"arrow-body-style": "off",
"prefer-arrow-callback": "off"
},
"settings": {
"prettier/prettier": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-explicit-any": "warn"
}
}
}
41 changes: 0 additions & 41 deletions .gitconsensus.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
6 changes: 2 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"editor.formatOnSave": true,
"semi": false,
"tabWidth": 4,
"semi": true,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid",
"trailingComma": "es5",
"endOfLine": "auto"
}
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# Simple Allies
Allows for simple communication between allies using a public segment

## Usage
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.

Plug this into your screeps bot and begin communicating with allies!
### Usage

- priority values should be from 0-1, where 1 is most preferred and 0 is least preferred
- avoid sending verbose data! The more data you send, the more expensive it is for your allies to parse and read it.
To integrate Simple Allies into your Screeps bot, import the necessary components from the project and incorporate them into your code.

### Code

For more details, refer to the source code:

- TypeScript source code: [src/](./src/)
- Built JavaScript code: [dist/](./dist/)

Please note that the JavaScript code is generated from the TypeScript source code and should be functionally identical.

### Contributing

Contributions are welcome! Feel free to submit a pull request.
69 changes: 69 additions & 0 deletions dist/exampleBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var simpleAllies = require('./simpleAllies.js');

/**
* Example bot loop
*/
function loop() {
// Read next an ally segment
simpleAllies.simpleAllies.initRun();
// Respond to ally requests
respondToAllyDefenseRequests();
respondToAllyResourceRequests();
// Request support from allies
requestAllyResources();
requestAllyDefense();
// Update ally segment
simpleAllies.simpleAllies.endRun();
}
/**
* Example of responding to ally defense requests
*/
function respondToAllyDefenseRequests() {
if (!simpleAllies.simpleAllies.allySegmentData)
return;
// Send creeps to defend rooms
for (const request of simpleAllies.simpleAllies.allySegmentData.requests.defense) {
console.log('[simpleAllies] Respond to defense request', JSON.stringify(request));
// ...
}
}
/**
* Example of responding to ally resource requests
*/
function respondToAllyResourceRequests() {
if (!simpleAllies.simpleAllies.allySegmentData)
return;
// Send resources to rooms
for (const request of simpleAllies.simpleAllies.allySegmentData.requests.resource) {
console.log('[simpleAllies] Respond to resource request', JSON.stringify(request));
// ...
}
}
/**
* Example of requesting ally resources
*/
function requestAllyResources() {
// Add resource request
simpleAllies.simpleAllies.requestResource({
priority: 1,
roomName: 'W1N1',
resourceType: RESOURCE_ENERGY,
amount: 1000,
});
}
/**
* Example of requesting ally defense
*/
function requestAllyDefense() {
// Add defense request
simpleAllies.simpleAllies.requestDefense({
priority: 1,
roomName: 'W1N1',
});
}

exports.loop = loop;
Loading

0 comments on commit 9426388

Please sign in to comment.