Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
feat(sens): added a flag argument to convert from cm/360|deg/mm|inch/360
Browse files Browse the repository at this point in the history
  • Loading branch information
animafps committed Jan 6, 2021
1 parent 2524480 commit 39378c9
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 78 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

analyze:
name: Analyze

Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
[![FPSMath](https://socialify.git.ci/animafps/fpsmath/image?description=1&font=Inter&language=1&logo=https%3A%2F%2Fcdn.discordapp.com%2Favatars%2F792712521546465301%2Fa8176886ccd814f17b4c5a98b62e185a.png%3Fsize%3D256&owner=1&pattern=Plus&theme=Dark)](#)
[![FPSMath](https://socialify.git.ci/animafps/fpsmath/image?description=1&font=Inter&language=1&logo=https%3A%2F%2Fcdn.discordapp.com%2Favatars%2F792712521546465301%2Fa8176886ccd814f17b4c5a98b62e185a.png%3Fsize%3D256&owner=1&pattern=Plus&theme=Dark)](https://github.com/AnimaFPS/FPSMath)

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/AnimaFPS/FPSMath?style=flat-square)](https://github.com/AnimaFPS/FPSMath/releases)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![CodeFactor](https://www.codefactor.io/repository/github/animafps/fpsmath/badge/main?style=flat-square)](https://www.codefactor.io/repository/github/animafps/fpsmath/overview/main)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/AnimaFPS/FPSMath/CI?logo=github&style=flat-square)](https://github.com/AnimaFPS/FPSMath/Actions)


## Installing

[Install This Bot on Your Server](https://discordapp.com/api/oauth2/authorize?client_id=792712521546465301&scope=bot&permissions=10240)

or build from source using Docker
or from source `npm ci` or `npm install` then `npm start`

Note: When building from source you have to input your own discord token in /src/config.json before building
Note: When building or runing from source you have to input your own discord token in /src/config.json or in the environment variables under `DISCORD_TOKEN` before building or running

## Usage

| Command | Arguments | Description | Example |
| --------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------- |
| /cm | <sensitivity value> <game or yaw value> <cpi/dpi> | Converts Senstivity to cm/360 | /cm 6 ow 1600 |
| /deg | <sensitivity value> <game or yaw value> <cpi/dpi> | Converts Senstivity to deg/mm | /deg 1.9 0.022 800 |
| /convert | <sensitivity value> <initial game or yaw value> <output game or yaw value> | Converts Different Sensitivities from one game to another | /convert 3 ow 0.022 |
| /fov | <input fov> <input aspect ratio or game> <output aspect ratio or game> | Converts fovs from one type to another or finds the equivilent for a differnet resolution aspect ratio | /fov 90 16:9 quake |
| /focal | <old sens> <old fov value> <new fov value> | Focal Length Scales a desired sens between 2 fov values of the same type | /focal 3 90 100 |
| /sens | <cm/360> <game or yaw value> <cpi/dpi> | Converts cm/360 to a game sensitivity | /sens 28 quake 1600 |
| /sens-deg | <deg/mm> <game or yaw value> <cpi/dpi> | Converts deg/mm to a game sensitivity | /sens-deg 1.28 quake 1600 |

## Supported Games and FOV Ratios
| Command | Arguments | Description | Example |
| -------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------- |
| /cm | <sens> <game|yaw> <cpi> | Converts Senstivity to cm/360 | /cm 6 ow 1600 |
| /deg | <sens> <game|yaw> <cpi> | Converts Senstivity to deg/mm | /deg 1.9 0.022 800 |
| /convert | <sens> <initial game|yaw> <output game|yaw> | Converts Different Sensitivities from one game to another | /convert 3 ow 0.022 |
| /fov | <input fov> <input aspect ratio|game> <output aspect ratio|game> | Converts fovs from one type to another or finds the equivilent for a differnet resolution aspect ratio | /fov 90 16:9 quake |
| /focal | <sens> <old fov> <new fov> | Focal Length Scales a desired sens between 2 fov values of the same type | /focal 3 90 100 |
| /sens | <cm/360> <game|yaw> <cpi/dpi> [-cm;-deg|-inch] | Converts cm/360|deg/mm|inch/360 to a game sensitivity | /sens 28 quake 1600 -cm |

## Supported Games

### Games

Expand Down
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const database = require('better-sqlite3');
const db = new database('settings.db');

const client = new commando.Client({
owner: ownerID,
commandPrefix: prefix,
invite: invite,
owner: process.env.OWENERID || ownerID,
commandPrefix: process.env.PREFIX || prefix,
invite: process.env.INVITE || invite,
});

client
Expand All @@ -21,7 +21,12 @@ client
`Client ready; logged in as ${client.user.username}#${client.user.discriminator} (${client.user.id})`
);
console.log(
`Running on servers: ${client.guilds.cache.array().join(', ')}`
`Running on servers: ${client.guilds.cache
.array()
.map(val => {
return `${val.name}(${val.memberCount})`;
})
.join(', ')}`
);
})
.on('disconnect', () => {
Expand Down Expand Up @@ -73,4 +78,5 @@ client.registry.commands
.filter(c => c.argsCollector)
.forEach(c => (c.argsCollector.promptLimit = 0));

client.login(token);
const Token = process.env.DISCORD_TOKEN || token;
client.login(Token);
1 change: 1 addition & 0 deletions src/commands/math/cm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = class cmCommand extends commando.Command {
description: 'Converts Senstivity to cm/360',
details: `Converts Senstivity to cm/360 \n (Supported Games: ${games()})`,
examples: ['`/cm 0.95 ow 1600`'],
format: '<sens> <game|yaw> <cpi>',

args: [
{
Expand Down
1 change: 1 addition & 0 deletions src/commands/math/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = class convertCommand extends commando.Command {
description: 'Converts Different Sensitivities from one game to another',
details: `Converts Different Sensitivities from one game to another \n (Supported Games: ${games()})`,
examples: ['`/convert 0.95 ow 0.022`'],
format: '<sens> <input game|yaw> <output game|yaw>',

args: [
{
Expand Down
1 change: 1 addition & 0 deletions src/commands/math/deg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = class degCommand extends commando.Command {
description: 'Converts Senstivity to deg/mm',
details: `Converts Senstivity to deg/mm \n (Supported Games: ${games()})`,
examples: ['`/deg 0.95 ow 1600`'],
format: '<sens> <game|yaw> <cpi>',

args: [
{
Expand Down
1 change: 1 addition & 0 deletions src/commands/math/focal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = class focalCommand extends commando.Command {
description:
'Focal Length Scales a desired sens between 2 fov values of the same type',
examples: ['`/focal 0.95 90 100`'],
format: '<sens> <old fov> <new fov>',

args: [
{
Expand Down
1 change: 1 addition & 0 deletions src/commands/math/fov.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = class fovCommand extends commando.Command {
'Converts fovs from one type to another or finds the true fov for a resolution aspect ratio',
details: `Converts fovs from one type to another or finds the true fov for a resolution aspect ratio(if the game scales to maintain vFOV) \n(Supported Games: ${games()})`,
examples: ['`/fov 90 quake 16:9`'],
format: '<fov> <input game|aspect ratio> <output game|aspect ratio>',

args: [
{
Expand Down
42 changes: 0 additions & 42 deletions src/commands/math/sens-deg.js

This file was deleted.

56 changes: 46 additions & 10 deletions src/commands/math/sens.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ module.exports = class sensCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'sens',
aliases: ['sens-cm'],
aliases: ['sens-cm', 'sens-deg', 'sens-inch'],
group: 'math',
memberName: 'sens',
description: 'Converts cm/360 to a game sensitivity',
details: `Converts cm/360 to a game sensitivity \n(Supported Games: ${games()})`,
examples: ['`/sens 28.5 quake 1600`'],
description: 'Converts cm/360|deg/mm|inch/360 to a game sensitivity',
details: `Converts cm/360|deg/mm|inch/360 to a game sensitivity \n(Supported Games: ${games()})`,
examples: [
'`/sens 28.5 quake 1600`',
'`/sens 28.5 ow 1600 -cm`',
'`/sens 1.21 cs 1600 -deg`',
'/sens 11.22 fortnite 1600 -inch',
],
format: '<cm/360|deg/mm|inch/360> <game|yaw> <cpi> [-cm|-deg|-inch]',

args: [
{
Expand All @@ -29,15 +35,45 @@ module.exports = class sensCommand extends commando.Command {
prompt: 'What CPI/DPI do you want to use',
type: 'float',
},
{
key: 'flags',
prompt: '',
default: '-cm',
type: 'string',
},
],
});
}

async run(message, args) {
const output = (
(2.54 * 360) /
(args.cpi * getObject(args.yawv, 'yaw') * args.cm)
).toFixed(2);
return message.say(output);
run(message, args) {
console.log(args.flags);
switch (args.flags) {
case '-deg': {
const output = (
(24.5 * args.cm) /
(args.cpi * getObject(args.yawv, 'yaw'))
).toFixed(2);
console.log(output);
message.say(output);
break;
}

case '-inch': {
const output = (
360 /
(args.cpi * getObject(args.yawv, 'yaw') * args.cm)
).toFixed(2);
message.say(output);
break;
}

case '-cm': {
const output = (
(2.54 * 360) /
(args.cpi * getObject(args.yawv, 'yaw') * args.cm)
).toFixed(2);
message.say(output);
}
}
}
};
6 changes: 3 additions & 3 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"token": "Discord bot token",
"ownerID": "owners discord it",
"prefix": "/",
"token": "",
"ownerID": "",
"prefix": "",
"invite": ""
}

0 comments on commit 39378c9

Please sign in to comment.