forked from ottomated/turtle-gambit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3464dc5
Showing
34 changed files
with
10,683 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# TODO | ||
|
||
✓ Place blocks | ||
✓ Break blocks | ||
- Craft items | ||
✓ Refuel | ||
✓ Display current fuel level | ||
✓ Show block name on mouse over | ||
✓ Drop items | ||
✓ Change inventory slot | ||
- Pathfinding? | ||
✓ Yoink items from chests | ||
* Move items in inventory | ||
- Equip items | ||
- Interface with peripherals? | ||
✓ Place signs | ||
|
||
# TURTLE MATERIALS | ||
- 7 iron ingots | ||
- 2 logs | ||
- 7 smooth stone | ||
- 1 redstone | ||
- 1 glass pane | ||
|
||
|
||
# GAMBIT MAIN PLAN | ||
|
||
1. Get ludwig to set up a single turtle. Ideally in town or a central area. | ||
2. Preparation. Mine for coal and resources to self-replicate. | ||
3. Advertisement. Start placing "Turtles are People" signs on the server. | ||
4. Contact Michael. Approach with turtle and: | ||
- ask to talk on discord / twitter? | ||
- link him to a screenshot of the UI | ||
- roleplay as the turtle: ask for fuel or something | ||
- obfuscate code and add twitter / discord as comment | ||
5. Michael gets Abe to whitelist me | ||
6. ?????? | ||
7. Profit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[1120/183326.479:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1120/204905.802:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1120/222506.283:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1120/234127.576:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/012540.708:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/021010.707:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/142532.002:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/143553.245:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/155937.617:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/162455.543:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/163833.780:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/171217.788:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/174932.629:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/181207.172:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/193659.416:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1121/201515.989:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1122/172427.761:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1122/190312.500:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1122/191337.607:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) | ||
[1122/195440.703:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# TypeScript Next.js example | ||
|
||
This is a really simple project that shows the usage of Next.js with TypeScript. | ||
|
||
## Deploy your own | ||
|
||
Deploy the example using [Vercel](https://vercel.com): | ||
|
||
[](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-typescript) | ||
|
||
## How to use it? | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: | ||
|
||
```bash | ||
npx create-next-app --example with-typescript with-typescript-app | ||
# or | ||
yarn create next-app --example with-typescript with-typescript-app | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). | ||
|
||
## Notes | ||
|
||
This example shows how to integrate the TypeScript type system into Next.js. Since TypeScript is supported out of the box with Next.js, all we have to do is to install TypeScript. | ||
|
||
``` | ||
npm install --save-dev typescript | ||
``` | ||
|
||
To enable TypeScript's features, we install the type declarations for React and Node. | ||
|
||
``` | ||
npm install --save-dev @types/react @types/react-dom @types/node | ||
``` | ||
|
||
When we run `next dev` the next time, Next.js will start looking for any `.ts` or `.tsx` files in our project and builds it. It even automatically creates a `tsconfig.json` file for our project with the recommended settings. | ||
|
||
Next.js has built-in TypeScript declarations, so we'll get autocompletion for Next.js' modules straight away. | ||
|
||
A `type-check` script is also added to `package.json`, which runs TypeScript's `tsc` CLI in `noEmit` mode to run type-checking separately. You can then include this, for example, in your `test` scripts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import Grid from '@material-ui/core/Grid'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Menu from '@material-ui/core/Menu'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import makeStyles from '@material-ui/core/styles/makeStyles'; | ||
import React, { useState } from 'react'; | ||
import { Turtle } from '../pages'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { hashCode } from './World'; | ||
import Color from 'color'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
|
||
inventory: { | ||
position: 'absolute', | ||
top: 100, | ||
left: 0, | ||
background: '#252525', | ||
height: 200, | ||
width: 200, | ||
zIndex: 10, | ||
borderRadius: 5, | ||
overflow: 'hidden' | ||
}, | ||
inventoryItem: { | ||
width: '25%', | ||
height: '25%', | ||
'& .MuiPaper-root': { | ||
height: '100%', | ||
width: '100%', | ||
border: '2px solid transparent', | ||
'&.selected': { | ||
borderColor: 'white' | ||
} | ||
}, | ||
cursor: 'pointer' | ||
} | ||
})); | ||
|
||
const initialState = { | ||
mouseX: null, | ||
mouseY: null, | ||
}; | ||
|
||
interface InventoryProps { | ||
turtle: Turtle; | ||
} | ||
|
||
export default function Inventory({ turtle }: InventoryProps) { | ||
const classes = useStyles(); | ||
const [state, setState] = useState<{ | ||
mouseX: null | number; | ||
mouseY: null | number; | ||
}>(initialState); | ||
const handleClick = (event: React.MouseEvent<HTMLDivElement>) => { | ||
event.preventDefault(); | ||
setState({ | ||
mouseX: event.clientX - 2, | ||
mouseY: event.clientY - 4, | ||
}); | ||
}; | ||
|
||
const handleClose = () => { | ||
setState(initialState); | ||
}; | ||
return ( | ||
<Grid container spacing={1} className={classes.inventory}> | ||
<Menu | ||
keepMounted | ||
open={state.mouseY !== null} | ||
onClose={handleClose} | ||
anchorReference="anchorPosition" | ||
anchorPosition={ | ||
state.mouseY !== null && state.mouseX !== null | ||
? { top: state.mouseY, left: state.mouseX } | ||
: undefined | ||
} | ||
> | ||
<MenuItem onClick={handleClose}>Copy</MenuItem> | ||
<MenuItem onClick={handleClose}>Print</MenuItem> | ||
<MenuItem onClick={handleClose}>Highlight</MenuItem> | ||
<MenuItem onClick={handleClose}>Email</MenuItem> | ||
</Menu> | ||
{ | ||
turtle.inventory.map((item, i) => ( | ||
<Grid key={i} item xs={3} className={classes.inventoryItem}> | ||
<Paper onContextMenu={handleClick} className={i + 1 === turtle.selectedSlot ? 'selected' : ''} style={{ | ||
background: item ? Color({ | ||
h: hashCode(item.name) % 360, | ||
s: 60, | ||
l: 40 | ||
}).toString() : undefined | ||
}} onClick={() => turtle.selectSlot(i + 1)}> | ||
{item && | ||
<Tooltip title={item.name}> | ||
<Typography align="center" variant="h4">{item.count}</Typography> | ||
</Tooltip> | ||
} | ||
</Paper> | ||
</Grid> | ||
)) | ||
} | ||
</Grid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import React, { useMemo, useState, useRef } from 'react'; | ||
import { Turtle, World, BlockDirection } from '../pages'; | ||
import Button from '@material-ui/core/Button'; | ||
import ButtonGroup, { ButtonGroupProps } from '@material-ui/core/ButtonGroup'; | ||
import ArrowDownward from '@material-ui/icons/ArrowDownward'; | ||
import ArrowUpward from '@material-ui/icons/ArrowUpward'; | ||
import CircularProgress, { CircularProgressProps } from '@material-ui/core/CircularProgress'; | ||
import Box from '@material-ui/core/Box'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { MuiThemeProvider, createMuiTheme, makeStyles } from '@material-ui/core/styles'; | ||
import Inventory from './Inventory'; | ||
import Dialog from '@material-ui/core/Dialog'; | ||
import DialogContent from '@material-ui/core/DialogContent'; | ||
import DialogTitle from '@material-ui/core/DialogTitle'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import DialogActions from '@material-ui/core/DialogActions/DialogActions'; | ||
import TurtleSwitcher from './TurtleSwitcher'; | ||
|
||
export interface TurtlePageProps { | ||
turtle: Turtle; | ||
enabled: boolean; | ||
} | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
toolbar: { | ||
display: 'flex', | ||
justifyContent: 'start', | ||
alignItems: 'center', | ||
background: '#252525', | ||
height: 100, | ||
width: '100%', | ||
}, | ||
groups: { | ||
'&>*': { | ||
marginLeft: theme.spacing(1), | ||
marginRight: theme.spacing(1), | ||
} | ||
} | ||
})); | ||
|
||
function CircularProgressWithLabel(props: CircularProgressProps) { | ||
return ( | ||
<Box style={{ position: 'relative', display: 'inline-flex' }}> | ||
<CircularProgress variant="static" {...props} /> | ||
<Box style={{ top: 0, left: 0, bottom: 0, right: 0, position: 'absolute', display: 'flex', alignItems: 'center', justifyContent: 'center' }} > | ||
<Typography variant="caption" component="div" color="textSecondary">{`${Math.round(props.value!)}%`}</Typography> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
|
||
export default function TurtlePage({ turtle, enabled }: TurtlePageProps) { | ||
const [signText, setSignText] = useState<string | null>(null); | ||
const currentSignDirection = useRef<BlockDirection>(BlockDirection.FORWARD); | ||
const classes = useStyles({ enabled }); | ||
|
||
const placeBlock = (dir: BlockDirection) => { | ||
if (turtle.inventory[turtle.selectedSlot - 1]?.name === 'minecraft:sign') { | ||
currentSignDirection.current = dir; | ||
setSignText(''); | ||
} else { | ||
turtle.place(dir); | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<Dialog disableBackdropClick open={signText !== null} onClose={() => setSignText(null)}> | ||
<DialogTitle>Sign Text</DialogTitle> | ||
<DialogContent> | ||
<TextField value={signText || ''} onChange={(ev) => setSignText(ev.target.value)} variant="outlined" /> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={() => setSignText(null)}>Cancel</Button> | ||
<Button onClick={() => { | ||
setSignText(null); | ||
turtle.place(currentSignDirection.current, signText!); | ||
}}>Place</Button> | ||
</DialogActions> | ||
</Dialog> | ||
<div className={classes.toolbar} style={{ display: enabled ? undefined : "none" }}> | ||
<Inventory turtle={turtle} /> | ||
<div className={classes.groups}> | ||
<TurtleButtonGroup turtle={turtle} func="dig" color='#e74c3c' /> | ||
<ColoredButtonGroup groupColor='#e67e22' size="small" orientation="vertical"> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => placeBlock(BlockDirection.UP)}><ArrowUpward /></Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => placeBlock(BlockDirection.FORWARD)}> | ||
place | ||
</Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => placeBlock(BlockDirection.DOWN)}><ArrowDownward /></Button> | ||
</ColoredButtonGroup> | ||
<TurtleButtonGroup turtle={turtle} func="suck" color='#f1c40f' /> | ||
<TurtleButtonGroup turtle={turtle} func="drop" color='#2ecc71' /> | ||
<ColoredButtonGroup size="small" orientation="vertical" groupColor='#3498db'> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle.refresh()}>Refresh Info</Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle.refuel()}>Refuel</Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle.undergoMitosis()}>Undergo Mitosis</Button> | ||
</ColoredButtonGroup> | ||
</div> | ||
<TurtleSwitcher /> | ||
<CircularProgressWithLabel variant="static" value={turtle.fuel / turtle.maxFuel * 100} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
interface TurtleButtonGroupProps { | ||
turtle: Turtle; | ||
func: 'place' | 'dig' | 'drop' | 'suck'; | ||
color: string; | ||
} | ||
|
||
function ColoredButtonGroup({ groupColor, ...props }: { groupColor: string } & ButtonGroupProps) { | ||
const theme = useMemo(() => createMuiTheme({ | ||
palette: { | ||
primary: { | ||
main: groupColor | ||
} | ||
}, | ||
}), [groupColor]); | ||
return ( | ||
<MuiThemeProvider theme={theme}> | ||
<ButtonGroup {...props} /> | ||
</MuiThemeProvider > | ||
); | ||
|
||
} | ||
|
||
function TurtleButtonGroup({ turtle, func, color }: TurtleButtonGroupProps) { | ||
return ( | ||
<ColoredButtonGroup groupColor={color} size="small" orientation="vertical"> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle[func](BlockDirection.UP)}><ArrowUpward /></Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle[func](BlockDirection.FORWARD)}> | ||
{func} | ||
</Button> | ||
<Button tabIndex="-1" variant="outlined" color="primary" onClick={() => turtle[func](BlockDirection.DOWN)}><ArrowDownward /></Button> | ||
</ColoredButtonGroup> | ||
); | ||
} |
Oops, something went wrong.